Repository: facebook/react
Pull request: Remove ReactTestUtils from ReactIdentity


Changed files:
filename: packages/react-dom/src/__tests__/ReactIdentity-test.js
patch: @@ -11,15 +11,13 @@
 
 let React;
 let ReactDOMClient;
-let ReactTestUtils;
 let act;
 
 describe('ReactIdentity', () => {
   beforeEach(() => {
     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 = <span />;
     const instance1 = <span />;
     const instance2 = <span />;
@@ -155,12 +153,16 @@ describe('ReactIdentity', () => {
       }
     }
 
-    expect(function () {
-      ReactTestUtils.renderIntoDocument(<TestContainer />);
-    }).not.toThrow();
+    const container = document.createElement('div');
+    const root = ReactDOMClient.createRoot(container);
+    await expect(
+      act(() => {
+        root.render(<TestContainer />);
+      }),
+    ).resolves.not.toThrow();
   });
 
-  it('should let nested restructures retain their uniqueness', () => {
+  it('should let nested restructures retain their uniqueness', async () => {
     const instance0 = <span />;
     const instance1 = <span />;
     const instance2 = <span />;
@@ -190,12 +192,16 @@ describe('ReactIdentity', () => {
       }
     }
 
-    expect(function () {
-      ReactTestUtils.renderIntoDocument(<TestContainer />);
-    }).not.toThrow();
+    const container = document.createElement('div');
+    const root = ReactDOMClient.createRoot(container);
+    await expect(
+      act(() => {
+        root.render(<TestContainer />);
+      }),
+    ).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(<TestContainer />);
-    }).not.toThrow();
+    const container = document.createElement('div');
+    const root = ReactDOMClient.createRoot(container);
+    await expect(
+      act(() => {
+        root.render(<TestContainer />);
+      }),
+    ).resolves.not.toThrow();
   });
 
   it('should retain key during updates in composite components', async () => {
@@ -272,17 +282,21 @@ 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 = (
       <div>
         <span />
         <span key="0" />
       </div>
     );
 
-    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 () => {