microsoft / microsoft/playwright
[Feature]: Add paused option to clock.install() to start with a frozen clock
Nobody has claimed this yet.
- 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
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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