Skip to content

Commit 87c803d

Browse files
authored
Fix a test case in ReactUpdates-test (#26399)
Just noticed the test isn't testing what it is meant to test properly. The error `Warning: ReactDOM.render is no longer supported in React 18. Use createRoot instead. Until you switch to the new API, your app will behave as if it's running React 17. Learn more: https://reactjs.org/link/switch-to-createroot` is thrown, the inner `expect(error).toContain('Warning: Maximum update depth exceeded.');` failed and threw jest error, and the outer `.toThrow('Maximum update depth exceeded.')` happens to catch it and makes the test pass.
1 parent eaccf27 commit 87c803d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,12 +1646,12 @@ describe('ReactUpdates', () => {
16461646
try {
16471647
const container = document.createElement('div');
16481648
expect(() => {
1649-
ReactDOM.render(<App />, container);
1649+
const root = ReactDOMClient.createRoot(container);
1650+
root.render(<App />);
16501651
while (error === null) {
16511652
Scheduler.unstable_flushNumberOfYields(1);
16521653
Scheduler.unstable_clearLog();
16531654
}
1654-
expect(error).toContain('Warning: Maximum update depth exceeded.');
16551655
expect(stack).toContain(' NonTerminating');
16561656
// rethrow error to prevent going into an infinite loop when act() exits
16571657
throw error;

0 commit comments

Comments
 (0)