diff --git a/packages/react-dom/src/__tests__/ReactIdentity-test.js b/packages/react-dom/src/__tests__/ReactIdentity-test.js index 5c25daf7d8f30..293916261cfc2 100644 --- a/packages/react-dom/src/__tests__/ReactIdentity-test.js +++ b/packages/react-dom/src/__tests__/ReactIdentity-test.js @@ -11,7 +11,6 @@ let React; let ReactDOMClient; -let ReactTestUtils; let act; describe('ReactIdentity', () => { @@ -19,7 +18,6 @@ describe('ReactIdentity', () => { jest.resetModules(); React = require('react'); ReactDOMClient = require('react-dom/client'); - ReactTestUtils = require('react-dom/test-utils'); act = require('internal-test-utils').act; }); @@ -127,7 +125,7 @@ describe('ReactIdentity', () => { expect(window.YOUVEBEENH4X0RED).toBe(undefined); }); - it('should let restructured components retain their uniqueness', () => { + it('should let restructured components retain their uniqueness', async () => { const instance0 = ; const instance1 = ; const instance2 = ; @@ -155,12 +153,16 @@ describe('ReactIdentity', () => { } } - expect(function () { - ReactTestUtils.renderIntoDocument(); - }).not.toThrow(); + const container = document.createElement('div'); + const root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render(); + }), + ).resolves.not.toThrow(); }); - it('should let nested restructures retain their uniqueness', () => { + it('should let nested restructures retain their uniqueness', async () => { const instance0 = ; const instance1 = ; const instance2 = ; @@ -190,12 +192,16 @@ describe('ReactIdentity', () => { } } - expect(function () { - ReactTestUtils.renderIntoDocument(); - }).not.toThrow(); + const container = document.createElement('div'); + const root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render(); + }), + ).resolves.not.toThrow(); }); - it('should let text nodes retain their uniqueness', () => { + it('should let text nodes retain their uniqueness', async () => { class TestComponent extends React.Component { render() { return ( @@ -218,9 +224,13 @@ describe('ReactIdentity', () => { } } - expect(function () { - ReactTestUtils.renderIntoDocument(); - }).not.toThrow(); + const container = document.createElement('div'); + const root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render(); + }), + ).resolves.not.toThrow(); }); it('should retain key during updates in composite components', async () => { @@ -272,7 +282,7 @@ describe('ReactIdentity', () => { expect(beforeB).toBe(afterB); }); - it('should not allow implicit and explicit keys to collide', () => { + it('should not allow implicit and explicit keys to collide', async () => { const component = (
@@ -280,9 +290,13 @@ describe('ReactIdentity', () => {
); - expect(function () { - ReactTestUtils.renderIntoDocument(component); - }).not.toThrow(); + const container = document.createElement('div'); + const root = ReactDOMClient.createRoot(container); + await expect( + act(() => { + root.render(component); + }), + ).resolves.not.toThrow(); }); it('should throw if key is a Temporal-like object', async () => {