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

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 force-pushed the useFakeTimers-bag-of-options branch 2 times, most recently from 3ab18f7 to 67d912f Compare Mar 12, 2022
@mrazauskas mrazauskas force-pushed the useFakeTimers-bag-of-options branch from 67d912f to 6b663c8 Compare Mar 12, 2022
@mrazauskas mrazauskas marked this pull request as draft Mar 12, 2022
@Biki-das
Copy link
Contributor

Biki-das commented Mar 15, 2022

@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

SimenB
SimenB approved these changes Apr 4, 2022
Copy link
Collaborator

@SimenB SimenB left a comment

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

mrazauskas commented Apr 5, 2022

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

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 facebook:main Apr 5, 2022
75 checks passed
@SimenB
Copy link
Collaborator

SimenB commented Apr 5, 2022

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

@mrazauskas
Copy link
Contributor Author

mrazauskas commented Apr 5, 2022

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

@mrazauskas mrazauskas deleted the useFakeTimers-bag-of-options branch Apr 5, 2022
@dannyharding10
Copy link

dannyharding10 commented Apr 5, 2022

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
Collaborator

SimenB commented Apr 5, 2022

@SimenB
Copy link
Collaborator

SimenB commented Apr 6, 2022

super happy with this diff at work 😀

image

@mrazauskas
Copy link
Contributor Author

mrazauskas commented Apr 7, 2022

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

SimenB commented Apr 7, 2022

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

image

@SimenB
Copy link
Collaborator

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.