-
-
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
Mock timestamp #4866
Mock timestamp #4866
Conversation
fdfe77f
to
efad34e
Compare
Codecov Report
@@ Coverage Diff @@
## master #4866 +/- ##
==========================================
+ Coverage 59.24% 59.25% +<.01%
==========================================
Files 200 200
Lines 6647 6648 +1
Branches 3 4 +1
==========================================
+ Hits 3938 3939 +1
Misses 2709 2709
Continue to review full report at Codecov.
|
packages/jest-mock/src/index.js
Outdated
@@ -313,6 +315,7 @@ class ModuleMockerClass { | |||
const mockConfig = mocker._ensureMockConfig(f); | |||
mockState.instances.push(this); | |||
mockState.calls.push(Array.prototype.slice.call(arguments)); | |||
mockState.timestamps.push(new Date().getTime()); |
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.
Date.now()
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.
Thanks for tackling this!
@SimenB I've updated this to use |
Unfortunately this will not solve #4402 if the calls happen at the same time (see jest-community/jest-extended#98 (comment)). |
@ChrisCinelli Confirming that I've run into the same problem too - Expected first mock to have been called before, timestamps:
[1517598132978]
Received second mock with timestamps:
[1517598132978] Is this a PR you're currently working on? :] |
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
This PR adds the internal behaviour to the mock state to record a timestamp on every invocation to allow community matchers to solve #4402.
I'm happy to add the matcher wanted in #4402 to jest-extended
Test plan