TOPIC 24/6018 MINNOT STARTED

Controlling time: the clock

Install Playwright's fake clock to freeze the date or skip ahead, so a 9 a.m. reminder or a 30-minute timeout is tested in a blink.

L1–L4 are part of the Pro pass

L0 Explain simply

Analogy: a film remote that can skip a day in a second. You watch a long film. With the remote you can pause on one frame, or jump forward an hour. The story does not need to run in real time for you to see what happens at the end.

Daily List is a to-do list app. It shows a toast, a small pop-up message, at 9 in the morning: "3 tasks due today". It signs a person out after 30 minutes with no activity. Tom, the tester, does not want to wait until 9, or sit for 30 minutes. He wants a remote.

The picture has limits. The remote only changes the clock inside the browser. The server has its own clock. The remote does not touch that clock.

What it is: Playwright is a free library from Microsoft that drives a real browser from code. This topic is one slice of that library: the on page.clock. Tom installs it before he opens the page, with await page.clock.install({ time: new Date('2026-12-01T08:55:00') }). The page then thinks it is five to nine. jumps ahead, with await page.clock.fastForward('10:00'). In this string, 10:00 means ten minutes, not ten hours. The page then thinks it is five past nine, and the toast shows. The nearest neighbour is a real await page.waitForTimeout(600000), which really waits ten minutes. The fake clock does not.

Why it matters: Reminders and sign-out depend on the clock. Without a fake clock, a 30-minute idle test takes 30 minutes, and a 9 a.m. toast can be checked only in the morning. With it, Tom asserts "3 tasks due today" in about a second, and he gets the same result every run. A hold is the control working. The test is not broken because it refused to sit and wait.

(SYNTHETIC / TRAINING ONLY: Daily List and every person named in this lesson are invented.)

PLAIN WORDS · 1 in this section
playwright
a free Microsoft tool that drives a browser for tests

PICTURE IT

The picture is the one the lesson above opens with. The table below shows how each part of it matches the software.

THE REAL JOB Skipping ahead in time, or freezing it, inside the browser, so a delay is tested in a blink.

  1. Install first
  2. Pause or skip
  3. Let the timers fire
  4. Check the screen
Pause or skip

HOW THE PICTURE MAPS

How each part of the picture matches the software
In the pictureIn the software
The film remoteThe fake clock
Pausing on one frameFixed time
Jumping forward an hourThe fast-forward
The film in the next roomThe server, with its own clock

WHERE THIS PICTURE STOPS

  • The remote changes the picture you watch. It does not change the film in another room.
  • A film has one clock. A test can use fixed time and a fast-forward in turn.
  • A remote works at once. The clock must be installed before the page loads.

HOOK

Pause or skip, then look.

REMEMBER IT THIS WAY

A sequence: the real steps, in order.

Pause or skip, then look: install the first, set the time, then jump forward and check the toast.

What each part of the trick stands for
In the trickWhat it stands for
pausefixed time
skipthe fast-forward
lookcheck the toast

The fake clock does not change the server, which keeps its own clock.

TELL A FRIEND

A film remote that pauses on one frame or jumps ahead an hour.

OFTEN MIXED UP WITH Dates, times and time zones. The general lesson explains why dates and time zones cause bugs. This lesson shows how to control time in a .

Sources & standards — 5 sources
  1. Market practice

    Clock (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes page.clock: install replaces time functions, setFixedTime freezes Date, pauseAt, fastForward and runFor move time, setSystemTime changes the clock without firing timers, and the clock covers the whole browser context. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. Also gives the string duration format ('01:00' is one minute) and says fastForward fires due timers at most once. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Auto-waiting (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Says Playwright runs actionability checks (visible, stable, enabled, receives events) before an action and fails with a timeout error if they do not pass in time. Vendor documentation. Practitioner or vendor guidance, not a standard unless stated. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  3. Market practice

    Configuration (use) (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Says which options belong in use and how baseURL makes relative paths work. Vendor documentation, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  4. Market practice

    Hypertext Transfer Protocol (HTTP) request methods (Mozilla developer docs) ↗ — Mozilla (MDN Web Docs) · Background on how a page asks a server for data (search excerpt, page not opened)

    Developer documentation. Describes GET as read only, POST as submit, PUT as replace and DELETE as remove. The search returned French and Spanish copies of this page. Search excerpt only. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  5. Market practice

    Clock | Playwright ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Clock methods and timer behavior. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Clock methods and timer behavior · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Clock methods and timer behavior. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

PRACTISE AND KEEP

Sources for this topic — 5 sources
  1. Market practice

    Clock (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Describes page.clock: install replaces time functions, setFixedTime freezes Date, pauseAt, fastForward and runFor move time, setSystemTime changes the clock without firing timers, and the clock covers the whole browser context. Vendor documentation for one tool. Practitioner or vendor guidance, not a standard. Also gives the string duration format ('01:00' is one minute) and says fastForward fires due timers at most once. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  2. Market practice

    Auto-waiting (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Says Playwright runs actionability checks (visible, stable, enabled, receives events) before an action and fails with a timeout error if they do not pass in time. Vendor documentation. Practitioner or vendor guidance, not a standard unless stated. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  3. Market practice

    Configuration (use) (Playwright documentation) ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Complete extracted primary article; examples inspected, not executed. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Says which options belong in use and how baseURL makes relative paths work. Vendor documentation, not a standard. · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Complete extracted primary article; examples inspected, not executed. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

  4. Market practice

    Hypertext Transfer Protocol (HTTP) request methods (Mozilla developer docs) ↗ — Mozilla (MDN Web Docs) · Background on how a page asks a server for data (search excerpt, page not opened)

    Developer documentation. Describes GET as read only, POST as submit, PUT as replace and DELETE as remove. The search returned French and Spanish copies of this page. Search excerpt only. · Checked 2026-10-18

    Found through a web search; the page was not opened (search excerpt, page not opened). Licence terms were not read, so put it in your own words and do not quote it. Open the page and confirm what it says before relying on any detail.

  5. Market practice

    Clock | Playwright ↗ — Microsoft (Playwright) · Reviewed 6 November 2026: Clock methods and timer behavior. See v45 source analysis for version scope and documented source ambiguities; no upstream run claimed.

    Clock methods and timer behavior · Checked 2026-11-06

    Primary source opened and operative text inspected on 6 November 2026. Scope: Clock methods and timer behavior. Current live Playwright documentation reflects 1.65 where stated; explicit older examples retain their version. Source inspection is not an execution or compatibility-test claim. See the completed v45 Playwright analysis for source discrepancies and exact reading boundaries.

Deepest material on this page: L4 — Standards & sources. Where a topic stops short of implementation depth, that is a deliberate coverage decision, not an oversight — see coverage.