-
-
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
feat: add fake timers implementation backed by Lolex #8897
Conversation
setImmediate(() => f()); | ||
jest.runAllImmediates(); | ||
expect(f.mock.calls.length).toBe(1); | ||
setTimeout(f, 0); |
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.
all of these changes does not strictly have to be here, but it's needed when we actually start using Lolex. Why not land the changes now 🤷♂
The reason for this change is that runAllImmediates
is not supported in the Lolex implementation
@@ -5,15 +5,16 @@ | |||
jest.useFakeTimers(); | |||
|
|||
it('schedules a 10-second timer after 1 second', () => { | |||
jest.spyOn(global, 'setTimeout'); |
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.
The reason for this change is that the fake timer functions in current implementation are mock functions, a feature I've purposefully not implemented in the Lolex version.
Codecov Report
@@ Coverage Diff @@
## master #8897 +/- ##
==========================================
+ Coverage 64.25% 64.27% +0.02%
==========================================
Files 275 276 +1
Lines 11657 11700 +43
Branches 2845 2860 +15
==========================================
+ Hits 7490 7520 +30
- Misses 3544 3549 +5
- Partials 623 631 +8
Continue to review full report at Codecov.
|
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. |
Summary
Adds the implementation of fake timers using Lolex from all of my other PRs. Note that this does not include a way to actually use this in Jest - It's just the implementation. This is not terribly useful on its own, but it makes it easier to keep up to date with the current implementation, and less rebasing work.
Test plan
Test added, which is a copy of the current tests with initialization changed for Lolex