@@ -12,13 +12,17 @@ let ReactDOM;
1212let ReactART ;
1313let ARTSVGMode ;
1414let ARTCurrentMode ;
15- let TestUtils ;
1615let TestRenderer ;
1716let ARTTest ;
1817
1918global . __DEV__ = process . env . NODE_ENV !== 'production' ;
2019global . __EXPERIMENTAL__ = process . env . RELEASE_CHANNEL === 'experimental' ;
2120
21+ jest . mock ( 'react-dom' , ( ) =>
22+ require . requireActual ( 'react-dom/cjs/react-dom-testing.development.js' )
23+ ) ;
24+ // we'll replace the above with react/testing and react-dom/testing right before the next minor
25+
2226expect . extend ( require ( '../toWarnDev' ) ) ;
2327
2428function App ( props ) {
@@ -32,7 +36,6 @@ beforeEach(() => {
3236 ReactART = require ( 'react-art' ) ;
3337 ARTSVGMode = require ( 'art/modes/svg' ) ;
3438 ARTCurrentMode = require ( 'art/modes/current' ) ;
35- TestUtils = require ( 'react-dom/test-utils' ) ;
3639 TestRenderer = require ( 'react-test-renderer' ) ;
3740
3841 ARTCurrentMode . setCurrent ( ARTSVGMode ) ;
@@ -70,8 +73,8 @@ beforeEach(() => {
7073} ) ;
7174
7275it ( "doesn't warn when you use the right act + renderer: dom" , ( ) => {
73- TestUtils . act ( ( ) => {
74- TestUtils . renderIntoDocument ( < App /> ) ;
76+ ReactDOM . act ( ( ) => {
77+ ReactDOM . render ( < App /> , document . createElement ( 'div' ) ) ;
7578 } ) ;
7679} ) ;
7780
@@ -86,7 +89,7 @@ it('resets correctly across renderers', () => {
8689 React . useEffect ( ( ) => { } , [ ] ) ;
8790 return null ;
8891 }
89- TestUtils . act ( ( ) => {
92+ ReactDOM . act ( ( ) => {
9093 TestRenderer . act ( ( ) => { } ) ;
9194 expect ( ( ) => {
9295 TestRenderer . create ( < Effecty /> ) ;
@@ -99,7 +102,7 @@ it('resets correctly across renderers', () => {
99102it ( 'warns when using the wrong act version - test + dom: render' , ( ) => {
100103 expect ( ( ) => {
101104 TestRenderer . act ( ( ) => {
102- TestUtils . renderIntoDocument ( < App /> ) ;
105+ ReactDOM . render ( < App /> , document . createElement ( 'div' ) ) ;
103106 } ) ;
104107 } ) . toWarnDev ( [ "It looks like you're using the wrong act()" ] , {
105108 withoutStack : true ,
@@ -113,7 +116,7 @@ it('warns when using the wrong act version - test + dom: updates', () => {
113116 setCtr = _setCtr ;
114117 return ctr ;
115118 }
116- TestUtils . renderIntoDocument ( < Counter /> ) ;
119+ ReactDOM . render ( < Counter /> , document . createElement ( 'div' ) ) ;
117120 expect ( ( ) => {
118121 TestRenderer . act ( ( ) => {
119122 setCtr ( 1 ) ;
@@ -123,7 +126,7 @@ it('warns when using the wrong act version - test + dom: updates', () => {
123126
124127it ( 'warns when using the wrong act version - dom + test: .create()' , ( ) => {
125128 expect ( ( ) => {
126- TestUtils . act ( ( ) => {
129+ ReactDOM . act ( ( ) => {
127130 TestRenderer . create ( < App /> ) ;
128131 } ) ;
129132 } ) . toWarnDev ( [ "It looks like you're using the wrong act()" ] , {
@@ -134,7 +137,7 @@ it('warns when using the wrong act version - dom + test: .create()', () => {
134137it ( 'warns when using the wrong act version - dom + test: .update()' , ( ) => {
135138 const root = TestRenderer . create ( < App key = "one" /> ) ;
136139 expect ( ( ) => {
137- TestUtils . act ( ( ) => {
140+ ReactDOM . act ( ( ) => {
138141 root . update ( < App key = "two" /> ) ;
139142 } ) ;
140143 } ) . toWarnDev ( [ "It looks like you're using the wrong act()" ] , {
@@ -151,15 +154,15 @@ it('warns when using the wrong act version - dom + test: updates', () => {
151154 }
152155 TestRenderer . create ( < Counter /> ) ;
153156 expect ( ( ) => {
154- TestUtils . act ( ( ) => {
157+ ReactDOM . act ( ( ) => {
155158 setCtr ( 1 ) ;
156159 } ) ;
157160 } ) . toWarnDev ( [ "It looks like you're using the wrong act()" ] ) ;
158161} ) ;
159162
160163it ( 'does not warn when nesting react-act inside react-dom' , ( ) => {
161- TestUtils . act ( ( ) => {
162- TestUtils . renderIntoDocument ( < ARTTest /> ) ;
164+ ReactDOM . act ( ( ) => {
165+ ReactDOM . render ( < ARTTest /> , document . createElement ( 'div' ) ) ;
163166 } ) ;
164167} ) ;
165168
@@ -171,7 +174,7 @@ it('does not warn when nesting react-act inside react-test-renderer', () => {
171174
172175it ( "doesn't warn if you use nested acts from different renderers" , ( ) => {
173176 TestRenderer . act ( ( ) => {
174- TestUtils . act ( ( ) => {
177+ ReactDOM . act ( ( ) => {
175178 TestRenderer . create ( < App /> ) ;
176179 } ) ;
177180 } ) ;
0 commit comments