@@ -12,13 +12,17 @@ let ReactDOM;
12
12
let ReactART ;
13
13
let ARTSVGMode ;
14
14
let ARTCurrentMode ;
15
- let TestUtils ;
16
15
let TestRenderer ;
17
16
let ARTTest ;
18
17
19
18
global . __DEV__ = process . env . NODE_ENV !== 'production' ;
20
19
global . __EXPERIMENTAL__ = process . env . RELEASE_CHANNEL === 'experimental' ;
21
20
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
+
22
26
expect . extend ( require ( '../toWarnDev' ) ) ;
23
27
24
28
function App ( props ) {
@@ -32,7 +36,6 @@ beforeEach(() => {
32
36
ReactART = require ( 'react-art' ) ;
33
37
ARTSVGMode = require ( 'art/modes/svg' ) ;
34
38
ARTCurrentMode = require ( 'art/modes/current' ) ;
35
- TestUtils = require ( 'react-dom/test-utils' ) ;
36
39
TestRenderer = require ( 'react-test-renderer' ) ;
37
40
38
41
ARTCurrentMode . setCurrent ( ARTSVGMode ) ;
@@ -70,8 +73,8 @@ beforeEach(() => {
70
73
} ) ;
71
74
72
75
it ( "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' ) ) ;
75
78
} ) ;
76
79
} ) ;
77
80
@@ -86,7 +89,7 @@ it('resets correctly across renderers', () => {
86
89
React . useEffect ( ( ) => { } , [ ] ) ;
87
90
return null ;
88
91
}
89
- TestUtils . act ( ( ) => {
92
+ ReactDOM . act ( ( ) => {
90
93
TestRenderer . act ( ( ) => { } ) ;
91
94
expect ( ( ) => {
92
95
TestRenderer . create ( < Effecty /> ) ;
@@ -99,7 +102,7 @@ it('resets correctly across renderers', () => {
99
102
it ( 'warns when using the wrong act version - test + dom: render' , ( ) => {
100
103
expect ( ( ) => {
101
104
TestRenderer . act ( ( ) => {
102
- TestUtils . renderIntoDocument ( < App /> ) ;
105
+ ReactDOM . render ( < App /> , document . createElement ( 'div' ) ) ;
103
106
} ) ;
104
107
} ) . toWarnDev ( [ "It looks like you're using the wrong act()" ] , {
105
108
withoutStack : true ,
@@ -113,7 +116,7 @@ it('warns when using the wrong act version - test + dom: updates', () => {
113
116
setCtr = _setCtr ;
114
117
return ctr ;
115
118
}
116
- TestUtils . renderIntoDocument ( < Counter /> ) ;
119
+ ReactDOM . render ( < Counter /> , document . createElement ( 'div' ) ) ;
117
120
expect ( ( ) => {
118
121
TestRenderer . act ( ( ) => {
119
122
setCtr ( 1 ) ;
@@ -123,7 +126,7 @@ it('warns when using the wrong act version - test + dom: updates', () => {
123
126
124
127
it ( 'warns when using the wrong act version - dom + test: .create()' , ( ) => {
125
128
expect ( ( ) => {
126
- TestUtils . act ( ( ) => {
129
+ ReactDOM . act ( ( ) => {
127
130
TestRenderer . create ( < App /> ) ;
128
131
} ) ;
129
132
} ) . 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()', () => {
134
137
it ( 'warns when using the wrong act version - dom + test: .update()' , ( ) => {
135
138
const root = TestRenderer . create ( < App key = "one" /> ) ;
136
139
expect ( ( ) => {
137
- TestUtils . act ( ( ) => {
140
+ ReactDOM . act ( ( ) => {
138
141
root . update ( < App key = "two" /> ) ;
139
142
} ) ;
140
143
} ) . 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', () => {
151
154
}
152
155
TestRenderer . create ( < Counter /> ) ;
153
156
expect ( ( ) => {
154
- TestUtils . act ( ( ) => {
157
+ ReactDOM . act ( ( ) => {
155
158
setCtr ( 1 ) ;
156
159
} ) ;
157
160
} ) . toWarnDev ( [ "It looks like you're using the wrong act()" ] ) ;
158
161
} ) ;
159
162
160
163
it ( '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' ) ) ;
163
166
} ) ;
164
167
} ) ;
165
168
@@ -171,7 +174,7 @@ it('does not warn when nesting react-act inside react-test-renderer', () => {
171
174
172
175
it ( "doesn't warn if you use nested acts from different renderers" , ( ) => {
173
176
TestRenderer . act ( ( ) => {
174
- TestUtils . act ( ( ) => {
177
+ ReactDOM . act ( ( ) => {
175
178
TestRenderer . create ( < App /> ) ;
176
179
} ) ;
177
180
} ) ;
0 commit comments