@samitouri / QOS-React-2 / commits / 87c803d1da

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.

Tianyu Yao committed Mar 16, 2023 at 12:27 UTC 87c803d1dad7e5fe8863436b0d2d18df3d462f21
1 file changed +2 -2
packages/react-dom/src/__tests__/ReactUpdates-test.js
+2 -2
@@ -1646,12 +1646,12 @@ describe('ReactUpdates', () => {
1646 try {
1647 const container = document.createElement('div');
1648 expect(() => {
1649 - ReactDOM.render(<App />, container);
1649 + const root = ReactDOMClient.createRoot(container);
1650 + root.render(<App />);
1651 while (error === null) {
1652 Scheduler.unstable_flushNumberOfYields(1);
1653 Scheduler.unstable_clearLog();
1654 }
1654 - expect(error).toContain('Warning: Maximum update depth exceeded.');
1655 expect(stack).toContain(' NonTerminating');
1656 // rethrow error to prevent going into an infinite loop when act() exits
1657 throw error;