Skip to content

Commit 2152c86

Browse files
Sebastian Silbermanneps1lon
authored andcommitted
fix: Remove redundant flush of microtask queue
1 parent da0ce9b commit 2152c86

File tree

1 file changed

+1
-29
lines changed

1 file changed

+1
-29
lines changed

src/pure.js

Lines changed: 1 addition & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -13,20 +13,6 @@ import act, {
1313
import {fireEvent} from './fire-event'
1414
import {getConfig, configure} from './config'
1515

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-
3016
configureDTL({
3117
unstable_advanceTimersWrapper: cb => {
3218
// Only needed to support test environments that enable fake timers after modules are loaded.
@@ -44,21 +30,7 @@ configureDTL({
4430
const previousActEnvironment = getIsReactActEnvironment()
4531
setReactActEnvironment(false)
4632
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()
6234
} finally {
6335
setReactActEnvironment(previousActEnvironment)
6436
}

0 commit comments

Comments
 (0)