microsoft / microsoft/playwright

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

Open
#42,536 6 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

P3-collecting-feedback
Dominant language
TypeScript
Stars
96.3k
Forks
6.5k
Avg merge
1d 6h
Merged PRs (30d)
180

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at the page.clock.install() API entry point and trace how its time and timer options are handled before page.clock.pauseAt(). Add support for paused: true so installation begins frozen, and verify that the example no longer requires a follow-up pauseAt() call or a guessed future timestamp.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
65/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.