From 87c803d1dad7e5fe8863436b0d2d18df3d462f21 Mon Sep 17 00:00:00 2001 From: Tianyu Yao Date: Thu, 16 Mar 2023 12:27:15 -0700 Subject: [PATCH] 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. --- packages/react-dom/src/__tests__/ReactUpdates-test.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/react-dom/src/__tests__/ReactUpdates-test.js b/packages/react-dom/src/__tests__/ReactUpdates-test.js index ef9766da96746..3c900a1987b2d 100644 --- a/packages/react-dom/src/__tests__/ReactUpdates-test.js +++ b/packages/react-dom/src/__tests__/ReactUpdates-test.js @@ -1646,12 +1646,12 @@ describe('ReactUpdates', () => { try { const container = document.createElement('div'); expect(() => { - ReactDOM.render(, container); + const root = ReactDOMClient.createRoot(container); + root.render(); while (error === null) { Scheduler.unstable_flushNumberOfYields(1); Scheduler.unstable_clearLog(); } - expect(error).toContain('Warning: Maximum update depth exceeded.'); expect(stack).toContain(' NonTerminating'); // rethrow error to prevent going into an infinite loop when act() exits throw error;