You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// codeconsttickThenTimeout=(state)=>{process.nextTick(()=>{setTimeout(()=>{state.ok=true;});});};// testit('tickThenTimeout should work',()=>{conststate={ok: false};timers.tickThenTimeout(state);expect(state.ok).toBe(false);jest.runAllTimers();expect(state.ok).toBe(true);});
This could make one believe that runAllTimers is a superset of runAllTicks. Current implementation here would also make one believe so, since it calls runAllTicks() at the beginning of the function.
But the following code/test don't work:
// codeconsttimeoutThenTick=(state)=>{setTimeout(()=>{process.nextTick(()=>{state.ok=true;});},0);};// testit('timeoutThenTick should work?',()=>{conststate={ok: false};timers.timeoutThenTick(state);expect(state.ok).toBe(false);jest.runAllTimers();expect(state.ok).toBe(true);});
My impression is that this behavior is inconsistent:
The docs mention that runAllTicks works exclusively for the micro-queue, and runAllTimers for the macro-queue. But the code above shows that runAllTimers affects both micro and macro tasks.
Even though runAllTimers dispatches micro-queues in some cases, it doesn't do so in all of them, as shown by test cases above.
If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can yarn install and yarn test.
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.
Do you want to request a feature or report a bug?
A bug, or a documentation issue.
What is the current behavior?
The following code and test work:
This could make one believe that
runAllTimers
is a superset ofrunAllTicks
. Current implementation here would also make one believe so, since it callsrunAllTicks()
at the beginning of the function.But the following code/test don't work:
My impression is that this behavior is inconsistent:
The docs mention that
runAllTicks
works exclusively for the micro-queue, andrunAllTimers
for the macro-queue. But the code above shows thatrunAllTimers
affects both micro and macro tasks.Even though
runAllTimers
dispatches micro-queues in some cases, it doesn't do so in all of them, as shown by test cases above.If the current behavior is a bug, please provide the steps to reproduce and either a repl.it demo through https://repl.it/languages/jest or a minimal repository on GitHub that we can
yarn install
andyarn test
.The following repo:
https://github.com/cesarkawakami/jest-bug-runalltimers
is
yarn test
-able for the behavior explained above.What is the expected behavior?
Both tests above pass /
yarn test
passes on given repository above.Please provide your exact Jest configuration and mention your Jest, node, yarn/npm version and operating system.
Jest: 19.0.2
Node: v7.6.0
Yarn: 0.18.2
OS: macOS Sierra 10.12.3
The text was updated successfully, but these errors were encountered: