-
Notifications
You must be signed in to change notification settings - Fork 232
Prove wait for works using useFakeTimers #637
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
Conversation
d9a4bf3
to
d80ddd8
Compare
Codecov Report
@@ Coverage Diff @@
## main #637 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 15 15
Lines 235 235
Branches 33 29 -4
=========================================
Hits 235 235 Continue to review full report at Codecov.
|
thanks again @chris110408! I'll wait for a resolution to the conversation in #631 before doing anything with this. |
6492ab0
to
fa84342
Compare
src/dom/__tests__/asyncHook.test.ts
Outdated
) | ||
|
||
expect(complete).toBe(true) | ||
jest.useRealTimers() |
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.
This should be in a catch
block. If the test fails, we don't want to the fake timers to break other tests in the file.
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.
Copy that makes sense. I will wrap the jest.useRealTimers()
in finally
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.
lol, yes, I meant finally
, not catch
... putting it in catch
would not be useful at all 🤦
@chris110408 I'm thinking of merging these tests but keeping #631 open until we get some clarification on what the actual issue is there, as I feel these represent valid ways of using fake timers and they will help ensure we don't accidentally break anything for the current functionality. I know it's annoying (read my thoughts on it here, but would you mind making variations for |
f9ed124
to
0aaf07a
Compare
0aaf07a
to
eff2ca6
Compare
What:
Fixes #631
Why:
Create the unit test to prove the wait for function works using jest.useFakeTimers
How:
Created a unit test use jest.useFakeTimers and jest.advanceTimersByTime()
Checklist: