diff --git a/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js b/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js index 53be0cbdb2d6d..a3a0d73e9a47e 100644 --- a/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js +++ b/packages/react-dom/src/__tests__/ReactTreeTraversal-test.js @@ -10,7 +10,9 @@ 'use strict'; let React; -let ReactDOM; +let ReactDOMClient; +let act; +let root; const ChildComponent = ({id, eventHandler}) => (
{ let outerNode1; let outerNode2; - beforeEach(() => { + beforeEach(async () => { React = require('react'); - ReactDOM = require('react-dom'); + ReactDOMClient = require('react-dom/client'); + act = require('internal-test-utils').act; mockFn.mockReset(); @@ -81,10 +84,14 @@ describe('ReactTreeTraversal', () => { document.body.appendChild(outerNode1); document.body.appendChild(outerNode2); - ReactDOM.render(, container); + root = ReactDOMClient.createRoot(container); + await act(() => { + root.render(); + }) }); afterEach(() => { + root.unmount(); document.body.removeChild(container); document.body.removeChild(outerNode1); document.body.removeChild(outerNode2);