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

feat(fake-timers)!: allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag #12572

Merged
merged 73 commits into from
Apr 5, 2022
Merged

feat(fake-timers)!: allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag #12572

merged 73 commits into from
Apr 5, 2022

Conversation

mrazauskas
Copy link
Contributor

@mrazauskas mrazauskas commented Mar 12, 2022

Resolves #8257 (allows jest.useFakeTimers({timerLimit: 10});)
Resolves #10602 (allows jest.useFakeTimers({advanceTimers: 30, now: new Date('2015-09-25')});)
Resolves #12055 (allows workaround jest.useFakeTimers({doNotFake: ['performance']});)
Closes #11661
Closes #12362
Closes #12452

Summary

As it is mentioned in the linked issues, it would be very useful to allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options object, which would configure underling @sinonjs/fake-timers. E.g. loopLimit, shouldAdvanceTime, toFake and all other options.

ToDo

  • unit test for the implementation
  • e2e tests for the new API
  • documentation
  • changelog entry

Test plan

Current and new unit, e2e and type tests should pass.

@mrazauskas mrazauskas marked this pull request as draft March 12, 2022 16:00
@Biki-das
Copy link
Contributor

@mrazauskas i had a doubt if you can explain and this is out of this pr, how is the deploy netlify preview configured in the codebase , anyone

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.

looking good!

packages/jest-config/src/Deprecated.ts Show resolved Hide resolved
packages/jest-jasmine2/src/index.ts Outdated Show resolved Hide resolved
@mrazauskas
Copy link
Contributor Author

@SimenB What if migration guide would be added? See last commit. This is just a draft, to illustrate the idea. Could be moved to separate PR and polished there.

@SimenB
Copy link
Member

SimenB commented Apr 5, 2022

Yeah, we can do an upgrade guide, I like it! I reverted that commit for now to land this, but a generic "how to upgrade to v28" sounds like a good idea to me! 👍 loooooooots of breaking changes

@SimenB SimenB changed the title feat (@jest/fake-timers)!: allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag feat(fake-timers)!: allow jest.useFakeTimers() and projectConfig.fakeTimers to take an options bag Apr 5, 2022
@SimenB SimenB merged commit 8aac27b into jestjs:main Apr 5, 2022
@SimenB
Copy link
Member

SimenB commented Apr 5, 2022

This is amazing work @mrazauskas, thank you so much!

@mrazauskas
Copy link
Contributor Author

Great! I will open a PR with How to Upgrade Guide.

@mrazauskas mrazauskas deleted the useFakeTimers-bag-of-options branch April 5, 2022 15:02
@danny-does-stuff
Copy link

Thank you for doing this @mrazauskas ! I've been following #11661 closely, and I'm very happy to see it resolved finally!

@SimenB
Copy link
Member

SimenB commented Apr 5, 2022

@SimenB
Copy link
Member

SimenB commented Apr 6, 2022

super happy with this diff at work 😀

image

@mrazauskas
Copy link
Contributor Author

@SimenB For some reason few recent updates of documentation are not yet included on Jest website. It either fails to rebuild or there are cache problems on my side. Can I ask to take a quick look? (;

@SimenB
Copy link
Member

SimenB commented Apr 7, 2022

Hmm, something is wrong with the deployment: https://app.netlify.com/sites/jestjs/deploys/624d79914cda8b0008589faa

image

@SimenB
Copy link
Member

SimenB commented Apr 7, 2022

@mrazauskas fixed now 🙂 Thanks for noticing!

@github-actions
Copy link

github-actions bot commented May 8, 2022

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 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.