Skip to content
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

Merged
merged 2 commits into from
Mar 4, 2019
Merged

Improve runAllTimers doc (it exhausts the micro-task queue) #8031

merged 2 commits into from
Mar 4, 2019

Conversation

dorian-marchal
Copy link
Contributor

Updates jest.runAllTimers() documentation to state that it also
exhausts the micro-task queue (this is the case since commit 9d17ea9).

Summary

Since #3915, jest.runAllTimers() is a superset of jest.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. 🙂

@facebook-github-bot
Copy link
Contributor

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!

docs/JestObjectAPI.md Outdated Show resolved Hide resolved
@SimenB SimenB requested a review from rickhanlonii March 3, 2019 17:24
Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks! Left an inline comment.

Can you also update the changelog, and the versioned docs?

image

@facebook-github-bot
Copy link
Contributor

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).
@dorian-marchal
Copy link
Contributor Author

Updated changelog and versionned docs. 📝

Copy link
Member

@SimenB SimenB left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@SimenB SimenB requested a review from thymikee March 3, 2019 17:42
@codecov-io
Copy link

Codecov Report

Merging #8031 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 4c25942...a29710d. Read the comment docs.

@@ -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`).
Copy link
Collaborator

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

Copy link
Member

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

Copy link
Collaborator

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

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@github-actions
Copy link

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.
Please note this issue tracker is not a help forum. We recommend using StackOverflow or our discord channel for questions.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 11, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.