-
-
Notifications
You must be signed in to change notification settings - Fork 6.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve runAllTimers doc (it exhausts the micro-task queue) #8031
Improve runAllTimers doc (it exhausts the micro-task queue) #8031
Conversation
Thank you for your pull request and welcome to our community. We require contributors to sign our Contributor License Agreement, and we don't seem to have you on file. In order for us to review and merge your code, please sign up at https://code.facebook.com/cla. If you are contributing on behalf of someone else (eg your employer), the individual CLA may not be sufficient and your employer may need the corporate CLA signed. If you have received this in error or have any questions, please contact us at cla@fb.com. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for signing our Contributor License Agreement. We can now accept your code for this (and any) Facebook open source project. Thanks! |
Updates `jest.runAllTimers()` documentation to state that it also exhausts the micro-task queue (this is the case since commit 9d17ea9).
Updated changelog and versionned docs. 📝 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Codecov Report
@@ Coverage Diff @@
## master #8031 +/- ##
=======================================
Coverage 63.31% 63.31%
=======================================
Files 263 263
Lines 10266 10266
Branches 2098 2098
=======================================
Hits 6500 6500
Misses 3273 3273
Partials 493 493 Continue to review full report at Codecov.
|
@@ -428,9 +428,9 @@ When this API is called, all pending micro-tasks that have been queued via `proc | |||
|
|||
### `jest.runAllTimers()` | |||
|
|||
Exhausts the **macro**-task queue (i.e., all tasks queued by `setTimeout()`, `setInterval()`, and `setImmediate()`). | |||
Exhausts both the **macro**-task queue (i.e., all tasks queued by `setTimeout()`, `setInterval()`, and `setImmediate()`) and the **micro**-task queue (usually interfaced in node via `process.nextTick`). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While we're at enumerating examples, let's add Promises next to process.nextTick
as they're used way more often and
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
By default, we don't exhaust it though - only if you've replaced Promise
with a fake one
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, that's a good point 🙈 we should at some point tho
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This pull request has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Updates
jest.runAllTimers()
documentation to state that it alsoexhausts the micro-task queue (this is the case since commit 9d17ea9).
Summary
Since #3915,
jest.runAllTimers()
is a superset ofjest.runAllTicks()
, but this is not explained in the documentation.Maybe this is implicit, but this was not clear to me until I came across #3915, so this is why I suggest this change. 🙂