mirror of
https://github.com/microsoft/vscode.git
synced 2026-07-10 16:58:55 -05:00
Sets virtual clock to a fixed date
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user