Skip to content

[Feature]: Add paused option to clock.install() to start with a frozen clock #42536

Description

🚀 Feature Request

A paused option on page.clock.install() that installs fake timers with the clock already frozen, so no follow-up pauseAt() call with a guessed future timestamp is needed.

Example

await page.clock.install({ time: START, paused: true });

Replaces the current two-step workaround, where the pause target has to be a guessed timestamp ahead of the install time to avoid cannot fast forward to the past:

await page.clock.install({ time: START });
await page.clock.pauseAt(PAUSE); // must be > START by more than the setup drift

Motivation

install() not freezing is surprising — sinon and jest freeze by default, so time silently keeps running and you suspect your own code first. The workaround is also fragile: install({ time: T }) followed by pauseAt(T) intermittently throws cannot fast forward to the past, because real time drifts forward between the two calls. That forces you to pick an arbitrary later timestamp — too close and it flakes, too far and it silently eats into the window you're asserting on.

A paused option removes the second call entirely, so there's no timestamp to guess and no drift to race.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions