From 2d03d75c49aa41190e71b941f22531b83a4fe080 Mon Sep 17 00:00:00 2001 From: Henning Dieterichs Date: Thu, 14 May 2026 21:22:18 +0200 Subject: [PATCH] Sets virtual clock to a fixed date --- .../test/browser/componentFixtures/fixtureUtils.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/vs/workbench/test/browser/componentFixtures/fixtureUtils.ts b/src/vs/workbench/test/browser/componentFixtures/fixtureUtils.ts index ad7130f0f7ee7..654184093cc2d 100644 --- a/src/vs/workbench/test/browser/componentFixtures/fixtureUtils.ts +++ b/src/vs/workbench/test/browser/componentFixtures/fixtureUtils.ts @@ -893,7 +893,14 @@ export function defineComponentFixture(options: ComponentFixtureOptions): Themed // during dispose to drain async cleanup work (e.g. `Promise.race` // guards behind `timeout(1000)` that hold references until they // settle) before the leak tracker checks for undisposed objects. - const clock = new VirtualClock(Date.now()); + // + // Seed the clock with a fixed wall-clock time so any code under + // test that reads `Date.now()` / `new Date()` produces the same + // values run after run. Real time would otherwise leak in + // through this seed and make screenshots that include + // time-derived labels (e.g. "1 hour ago", "Today") drift + // across days, hour boundaries, and DST changes. + const clock = new VirtualClock(new Date('2026-05-14T12:00:00Z').getTime()); const p = new VirtualTimeProcessor( clock, drainMicrotasksEmbedding(realTimeApi),