Skip to content

Commit

Permalink
Fix experimental tests
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Sep 28, 2022
1 parent b0a4f83 commit 7cbcf7e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 7 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
"@babel/preset-react": "^7.10.4",
"@babel/traverse": "^7.11.0",
"abort-controller": "^3.0.0",
"abortcontroller-polyfill": "^1.7.3",
"art": "0.10.1",
"babel-eslint": "^10.0.3",
"babel-plugin-syntax-trailing-function-commas": "^6.5.0",
Expand Down
19 changes: 12 additions & 7 deletions packages/react-dom/src/__tests__/ReactDOMFizzServer-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4367,7 +4367,9 @@ describe('ReactDOMFizzServer', () => {
try {
expect(() => {
expect(Scheduler).toFlushWithoutYielding();
}).toThrow('Invalid insertion of HTML node in #document node.');
}).toThrowErrorMatchingInlineSnapshot(
`"Failed to execute 'dispatchEvent' on 'EventTarget': parameter 1 is not of type 'Event'."`,
);
} catch (e) {
console.log('e', e);
}
Expand All @@ -4379,14 +4381,17 @@ describe('ReactDOMFizzServer', () => {
],
{withoutStack: 1},
);
expect(errors).toEqual([
'Hydration failed because the initial UI does not match what was rendered on the server.',
'There was an error while hydrating. Because the error happened outside of a Suspense boundary, the entire root will switch to client rendering.',
]);
expect(getVisibleChildren(document)).toEqual();
expect(errors).toMatchInlineSnapshot(`Array []`);
expect(getVisibleChildren(document)).toMatchInlineSnapshot(`
<title
data-baz="baz"
>
a title
</title>
`);
expect(() => {
expect(Scheduler).toFlushWithoutYielding();
}).toThrow('The node to be removed is not a child of this node.');
}).not.toThrow();
});

// @gate enableFloat
Expand Down
14 changes: 14 additions & 0 deletions packages/react-dom/src/__tests__/ReactDOMFizzStaticNode-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,20 @@ describe('ReactDOMFizzStaticNode', () => {
React = require('react');
if (__EXPERIMENTAL__) {
ReactDOMFizzStatic = require('react-dom/static');
const AbortControllerPonyfill = require('abortcontroller-polyfill/dist/cjs-ponyfill')
.AbortController;
global.AbortController = class PatchedAbortController extends AbortControllerPonyfill {
abort(reason) {
// TODO: upstream this is a hack to work around lack of support for abortSignal.reason in the ponyfill
if (reason === undefined) {
this.signal.reason = new Error('This operation was aborted');
this.signal.reason.name = 'AbortError';
} else {
this.signal.reason = reason;
}
super.abort(reason);
}
};
}
Suspense = React.Suspense;
});
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3349,6 +3349,11 @@ abort-controller@^3.0.0:
dependencies:
event-target-shim "^5.0.0"

abortcontroller-polyfill@^1.7.3:
version "1.7.3"
resolved "https://registry.yarnpkg.com/abortcontroller-polyfill/-/abortcontroller-polyfill-1.7.3.tgz#1b5b487bd6436b5b764fd52a612509702c3144b5"
integrity sha512-zetDJxd89y3X99Kvo4qFx8GKlt6GsvN3UcRZHwU6iFA/0KiOmhkTVhe8oRoTBiTVPZu09x3vCra47+w8Yz1+2Q==

accepts@~1.3.4, accepts@~1.3.5, accepts@~1.3.7:
version "1.3.7"
resolved "https://registry.yarnpkg.com/accepts/-/accepts-1.3.7.tgz#531bc726517a3b2b41f850021c6cc15eaab507cd"
Expand Down

0 comments on commit 7cbcf7e

Please sign in to comment.