-
-
Notifications
You must be signed in to change notification settings - Fork 281
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
test: update clock tests to run deterministically #6828
test: update clock tests to run deterministically #6828
Conversation
beforeEach(() => { | ||
vi.setSystemTime(genesisTime * 1000); | ||
}); |
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.
We are using vi.useFakeTimers({now: Date.now()});
that config now
is enough to make the tests deterministic. If any regression detected we should try to hardcode value now
to a static value.
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.
that config now is enough to make the tests deterministic
but the test is not deterministic, see #6734 (comment)
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.
Another failed run on unstable, we should merge this
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.
LGTM, just need to fix the lint issues
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## unstable #6828 +/- ##
============================================
- Coverage 62.21% 62.19% -0.02%
============================================
Files 571 571
Lines 60017 60021 +4
Branches 1975 1973 -2
============================================
- Hits 37338 37333 -5
- Misses 22636 22645 +9
Partials 43 43 |
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.
LGTM!! 🎸
🎉 This PR is included in v1.20.0 🎉 |
Motivation
Clock tests at
clock.test.ts
keep failing from time to time due to edge cases arising from the use ofDate.now
This aims to fix that.
Description
This change overrides the system time before each test case to make the tests run deterministically.
Closes #6734