@@ -13,20 +13,6 @@ import act, {
13
13
import { fireEvent } from './fire-event'
14
14
import { getConfig , configure } from './config'
15
15
16
- function jestFakeTimersAreEnabled ( ) {
17
- /* istanbul ignore else */
18
- if ( typeof jest !== 'undefined' && jest !== null ) {
19
- return (
20
- // legacy timers
21
- setTimeout . _isMockFunction === true || // modern timers
22
- // eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support.
23
- Object . prototype . hasOwnProperty . call ( setTimeout , 'clock' )
24
- )
25
- } // istanbul ignore next
26
-
27
- return false
28
- }
29
-
30
16
configureDTL ( {
31
17
unstable_advanceTimersWrapper : cb => {
32
18
// Only needed to support test environments that enable fake timers after modules are loaded.
@@ -44,21 +30,7 @@ configureDTL({
44
30
const previousActEnvironment = getIsReactActEnvironment ( )
45
31
setReactActEnvironment ( false )
46
32
try {
47
- const result = await cb ( )
48
- // Drain microtask queue.
49
- // Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call.
50
- // The caller would have no chance to wrap the in-flight Promises in `act()`
51
- await new Promise ( resolve => {
52
- setTimeout ( ( ) => {
53
- resolve ( )
54
- } , 0 )
55
-
56
- if ( jestFakeTimersAreEnabled ( ) ) {
57
- jest . advanceTimersByTime ( 0 )
58
- }
59
- } )
60
-
61
- return result
33
+ return await cb ( )
62
34
} finally {
63
35
setReactActEnvironment ( previousActEnvironment )
64
36
}
0 commit comments