Skip to content

Commit f01dd3d

Browse files
committed
Update test
1 parent 0ad2574 commit f01dd3d

File tree

2 files changed

+34
-15
lines changed

2 files changed

+34
-15
lines changed

packages/react-dom/src/__tests__/ReactComponent-test.js

Lines changed: 32 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,25 @@ describe('ReactComponent', () => {
2626
act = require('internal-test-utils').act;
2727
});
2828

29-
// @gate !disableLegacyMode
29+
// @gate !disableLegacyMode && www
3030
it('should throw on invalid render targets in legacy roots', () => {
3131
const container = document.createElement('div');
3232
// jQuery objects are basically arrays; people often pass them in by mistake
33-
expect(function () {
34-
ReactDOM.render(<div />, [container]);
35-
}).toThrowError(/Target container is not a DOM element./);
36-
37-
expect(function () {
38-
ReactDOM.render(<div />, null);
39-
}).toThrowError(/Target container is not a DOM element./);
33+
expect(() => {
34+
expect(function () {
35+
ReactDOM.render(<div />, [container]);
36+
}).toThrowError(/Target container is not a DOM element./);
37+
38+
expect(function () {
39+
ReactDOM.render(<div />, null);
40+
}).toThrowError(/Target container is not a DOM element./);
41+
}).toErrorDev(
42+
[
43+
'ReactDOM.render is no longer supported in React 18.',
44+
'ReactDOM.render is no longer supported in React 18.',
45+
],
46+
{withoutStack: true},
47+
);
4048
});
4149

4250
// @gate !disableStringRefs
@@ -456,16 +464,25 @@ describe('ReactComponent', () => {
456464
/* eslint-enable indent */
457465
});
458466

459-
// @gate !disableLegacyMode
467+
// @gate !disableLegacyMode && www
460468
it('fires the callback after a component is rendered in legacy roots', () => {
461469
const callback = jest.fn();
462470
const container = document.createElement('div');
463-
ReactDOM.render(<div />, container, callback);
464-
expect(callback).toHaveBeenCalledTimes(1);
465-
ReactDOM.render(<div className="foo" />, container, callback);
466-
expect(callback).toHaveBeenCalledTimes(2);
467-
ReactDOM.render(<span />, container, callback);
468-
expect(callback).toHaveBeenCalledTimes(3);
471+
expect(() => {
472+
ReactDOM.render(<div />, container, callback);
473+
expect(callback).toHaveBeenCalledTimes(1);
474+
ReactDOM.render(<div className="foo" />, container, callback);
475+
expect(callback).toHaveBeenCalledTimes(2);
476+
ReactDOM.render(<span />, container, callback);
477+
expect(callback).toHaveBeenCalledTimes(3);
478+
}).toErrorDev(
479+
[
480+
'ReactDOM.render is no longer supported in React 18.',
481+
'ReactDOM.render is no longer supported in React 18.',
482+
'ReactDOM.render is no longer supported in React 18.',
483+
],
484+
{withoutStack: true},
485+
);
469486
});
470487

471488
it('throws usefully when rendering badly-typed elements', async () => {

packages/react-test-renderer/src/__tests__/ReactTestRenderer-test.internal.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ describe('ReactTestRenderer', () => {
9898
null,
9999
expect.anything(),
100100
expect.anything(),
101+
expect.anything(),
102+
expect.anything(),
101103
null,
102104
);
103105
}

0 commit comments

Comments
 (0)