Skip to content

Commit

Permalink
fix: Remove redundant flush of microtask queue
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Silbermann committed May 28, 2023
1 parent 4961964 commit 8669481
Showing 1 changed file with 1 addition and 15 deletions.
16 changes: 1 addition & 15 deletions src/pure.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,21 +43,7 @@ configureDTL({
const previousActEnvironment = getIsReactActEnvironment()
setReactActEnvironment(false)
try {
const result = await cb()
// Drain microtask queue.
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call.
// The caller would have no chance to wrap the in-flight Promises in `act()`
await new Promise(resolve => {
setTimeout(() => {
resolve()
}, 0)

if (jestFakeTimersAreEnabled()) {
jest.advanceTimersByTime(0)
}
})

return result
return await cb()
} finally {
setReactActEnvironment(previousActEnvironment)
}
Expand Down

0 comments on commit 8669481

Please sign in to comment.