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

docs: fix setTimeout example #11974

Merged
merged 2 commits into from Oct 18, 2021
Merged

docs: fix setTimeout example #11974

merged 2 commits into from Oct 18, 2021

Conversation

posva
Copy link
Contributor

@posva posva commented Oct 18, 2021

Based on #11447 (comment)

Summary

Without this snippets jest will error that setTimeout is not a mock

Test plan

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! This is true with the modern fake timers, which is the default from jest 27. Could you update the other versions of this as well?

image

@posva
Copy link
Contributor Author

posva commented Oct 18, 2021

Oh, I didn't see this was duplicated 😆 Thanks for pointing out the files 🙌

@@ -25,6 +25,7 @@ module.exports = timerGame;
'use strict';

jest.useFakeTimers();
jest.spyOn(global, 'setTimeout');
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I also changed this one but let me know if I should remove it

Copy link
Member

Choose a reason for hiding this comment

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

ah, good catch! that's correct 🙂

@codecov-commenter
Copy link

Codecov Report

Merging #11974 (41aa0d9) into main (e7edb75) will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##             main   #11974   +/-   ##
=======================================
  Coverage   68.74%   68.74%           
=======================================
  Files         323      323           
  Lines       16649    16649           
  Branches     4805     4805           
=======================================
  Hits        11445    11445           
  Misses       5171     5171           
  Partials       33       33           

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 e7edb75...41aa0d9. Read the comment docs.

@SimenB SimenB merged commit a1829e9 into jestjs:main Oct 18, 2021
@posva posva deleted the patch-1 branch October 18, 2021 15:32
@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 Nov 18, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants