4
4
* This source code is licensed under the MIT license found in the
5
5
* LICENSE file in the root directory of this source tree.
6
6
*/
7
- import type { Thenable } from 'react-reconciler/src/ReactFiberWorkLoop' ;
8
7
9
8
import React from 'react' ;
10
9
import ReactDOM from 'react-dom' ;
@@ -19,7 +18,6 @@ import {
19
18
import SyntheticEvent from 'events/SyntheticEvent' ;
20
19
import invariant from 'shared/invariant' ;
21
20
import lowPriorityWarning from 'shared/lowPriorityWarning' ;
22
- import warningWithoutStack from 'shared/warningWithoutStack' ;
23
21
import { ELEMENT_NODE } from '../shared/HTMLNodeType' ;
24
22
import * as DOMTopLevelEventTypes from '../events/DOMTopLevelEventTypes' ;
25
23
import { PLUGIN_EVENT_SYSTEM } from 'events/EventSystemFlags' ;
@@ -153,12 +151,6 @@ function validateClassInstance(inst, methodName) {
153
151
) ;
154
152
}
155
153
156
- // a plain dom element, lazily initialized, used by act() when flushing effects
157
- let actContainerElement = null ;
158
-
159
- // a warning for when you try to use TestUtils.act in a non-browser environment
160
- let didWarnAboutActInNodejs = false ;
161
-
162
154
/**
163
155
* Utilities for making it easy to test React components.
164
156
*
@@ -395,25 +387,7 @@ const ReactTestUtils = {
395
387
Simulate : null ,
396
388
SimulateNative : { } ,
397
389
398
- act ( callback : ( ) => Thenable ) {
399
- if ( actContainerElement === null ) {
400
- if ( __DEV__ ) {
401
- // warn if we're trying to use this in something like node (without jsdom)
402
- if ( didWarnAboutActInNodejs === false ) {
403
- didWarnAboutActInNodejs = true ;
404
- warningWithoutStack (
405
- typeof document !== 'undefined' && document !== null ,
406
- 'It looks like you called ReactTestUtils.act(...) in a non-browser environment. ' +
407
- "If you're using TestRenderer for your tests, you should call " +
408
- 'ReactTestRenderer.act(...) instead of ReactTestUtils.act(...).' ,
409
- ) ;
410
- }
411
- }
412
- // now make the stub element
413
- actContainerElement = document . createElement ( 'div' ) ;
414
- }
415
- return act ( callback ) ;
416
- } ,
390
+ act,
417
391
} ;
418
392
419
393
/**
0 commit comments