Skip to content

Commit d935fb1

Browse files
committed
Implementation without macrotask
1 parent d2940a5 commit d935fb1

File tree

1 file changed

+1
-22
lines changed

1 file changed

+1
-22
lines changed

src/pure.js

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +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-
Object.prototype.hasOwnProperty.call(setTimeout, 'clock')
22-
)
23-
} // istanbul ignore next
24-
25-
return false
26-
}
27-
2815
configureDTL({
2916
unstable_advanceTimersWrapper: cb => {
3017
return act(cb)
@@ -40,15 +27,7 @@ configureDTL({
4027
// Drain microtask queue.
4128
// Otherwise we'll restore the previous act() environment, before we resolve the `waitFor` call.
4229
// The caller would have no chance to wrap the in-flight Promises in `act()`
43-
await new Promise(resolve => {
44-
setTimeout(() => {
45-
resolve()
46-
}, 0)
47-
48-
if (jestFakeTimersAreEnabled()) {
49-
jest.advanceTimersByTime(0)
50-
}
51-
})
30+
await Promise.resolve().then(() => {})
5231

5332
return result
5433
} finally {

0 commit comments

Comments
 (0)