Repository navigation
test(junior): Start every test at the start of a clock minute - #3478
Merged
Merged
Conversation
Move the eval clock to @sentry/junior-testing/clock and use it in the junior Vitest setup. Date starts each test file and each test at 2026-10-01T12:05:00Z and moves forward in real time. Fake timers from a test no longer leak into the next test. Two tests compare times with a clock outside the process (Postgres now(), a real S3 server) and opt out with useRealClock(). The versions API test drops its own pin. Co-Authored-By: David Cramer <[email protected]>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
|
31 screenshot changes — 31 changed · 0 added · 0 removed Review screenshots in Frameshift Show 12 more changed screenshots13 more changed screenshots in Frameshift. |
Start Date 5 s after the current real minute instead of at a fixed 2026 instant. Date then stays within a minute of Postgres now(), so the S3 and auto-archive tests no longer need an opt-out, and useRealClock() is gone. Co-Authored-By: David Cramer <[email protected]>
dcramer
approved these changes
Nov 16, 2026
23 tasks done
This branch was successfully deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
In the junior Vitest suite,
Datenow starts each test file and each test 5 s after the start of the current real minute, and then moves forward in real time. This is the offset clock the evals already use. It moves fromjunior-evals/src/eval-clock.tsto@sentry/junior-testing/clock, and the evals import it from there.Why
Recent fixes for nondeterministic tests, grouped by mechanism:
closeAllConnections()The only mechanism with no harness default was the wall clock in the junior Vitest suite, so this PR changes only that.
What the harness guarantees
versions.test.tsdrops its own pin.Datestays within a minute of real time. Times that JS stamps stay comparable with Postgresnow(),defaultNow()columns, and real servers such as S3, so no test needs an opt-out. A fixed calendar instant would putDateweeks away from those clocks.performance.now()stay real. Sinon's Date-only fake (shouldAdvanceTime) moves in 20 ms steps and does not move during microtask-only work. Timestamps would then tie and makeORDER BY created_atflaky, so this PR does not use it.vi.useFakeTimers(),vi.setSystemTime(), andvi.spyOn(Date, "now")work on top of the clock.afterEachcallsvi.useRealTimers(), so fake timers do not leak into the next test. A test that forgetsvi.useRealTimers()no longer shows up as a leak in later tests.Left out
vi.setSystemTimepins still work and stay as they are.via @dcramer.
--
View Session [Sentry]