Skip to content

Commit b5cf504

Browse files
Sebastian Silbermanneps1lon
Sebastian Silbermann
authored andcommitted
fix: Remove redundant flush of microtask queue
1 parent 00c3484 commit b5cf504

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
// Only needed to support test environments that enable fake timers after modules are loaded.
@@ -43,21 +29,7 @@ configureDTL({
4329
const previousActEnvironment = getIsReactActEnvironment()
4430
setReactActEnvironment(false)
4531
try {
46-
const result = await cb()
47-
// Drain microtask queue.
48-
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call.
49-
// The caller would have no chance to wrap the in-flight Promises in `act()`
50-
await new Promise(resolve => {
51-
setTimeout(() => {
52-
resolve()
53-
}, 0)
54-
55-
if (jestFakeTimersAreEnabled()) {
56-
jest.advanceTimersByTime(0)
57-
}
58-
})
59-
60-
return result
32+
return await cb()
6133
} finally {
6234
setReactActEnvironment(previousActEnvironment)
6335
}

0 commit comments

Comments
 (0)