Skip to content

Commit 7cf22ce

Browse files
committed
fix: Remove redundant microtask flush
1 parent 5dc81dc commit 7cf22ce

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

src/pure.js

+1-29
Original file line numberDiff line numberDiff line change
@@ -12,20 +12,6 @@ import act, {
1212
} from './act-compat'
1313
import {fireEvent} from './fire-event'
1414

15-
function jestFakeTimersAreEnabled() {
16-
/* istanbul ignore else */
17-
if (typeof jest !== 'undefined' && jest !== null) {
18-
return (
19-
// legacy timers
20-
setTimeout._isMockFunction === true || // modern timers
21-
// eslint-disable-next-line prefer-object-has-own -- No Object.hasOwn in all target environments we support.
22-
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
23-
)
24-
} // istanbul ignore next
25-
26-
return false
27-
}
28-
2915
configureDTL({
3016
unstable_advanceTimersWrapper: cb => {
3117
return act(cb)
@@ -37,21 +23,7 @@ configureDTL({
3723
const previousActEnvironment = getIsReactActEnvironment()
3824
setReactActEnvironment(false)
3925
try {
40-
const result = await cb()
41-
// Drain microtask queue.
42-
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call.
43-
// The caller would have no chance to wrap the in-flight Promises in `act()`
44-
await new Promise(resolve => {
45-
setTimeout(() => {
46-
resolve()
47-
}, 0)
48-
49-
if (jestFakeTimersAreEnabled()) {
50-
jest.advanceTimersByTime(0)
51-
}
52-
})
53-
54-
return result
26+
return await cb()
5527
} finally {
5628
setReactActEnvironment(previousActEnvironment)
5729
}

0 commit comments

Comments
 (0)