new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Playwright · API reference · all subjects

clock/methods

19 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Clock.resume method

Async method available since v1.45. Resumes timers. Once called, time resumes flowing and timers are fired as usual.

Clock.fastForward method

Async method available since v1.45. Advances the clock by jumping forward in time. Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it later, after given time. Takes parameter 'ticks' of type long or string.

Clock.fastForward ticks parameter formats

The 'ticks' parameter can be a number of milliseconds (long) or a human-readable string. Valid string formats are: '08' for eight seconds, '01:00' for one minute, and '02:34:10' for two hours, 34 minutes and ten seconds.

Clock.install method

Async method available since v1.45. Installs fake implementations for time-related functions: Date, setTimeout, clearTimeout, setInterval, clearInterval, requestAnimationFrame, cancelAnimationFrame, requestIdleCallback, cancelIdleCallback, and performance. Fake timers allow manual control of time flow in tests.

Clock.install time option for JavaScript and Java

The 'time' option for Clock.install in JavaScript and Java languages is of type long, string, or Date. It specifies the time to initialize with, defaulting to current system time if not provided.

Clock.install time option for Python

The 'time' option for Clock.install in Python is of type float, string, or Date. Numeric values are Unix time in seconds. It specifies the time to initialize with, defaulting to current system time if not provided.

Clock.install time option for C#

The 'time' option for Clock.install in C# is of type string or Date. It specifies the time to initialize with, defaulting to current system time if not provided.

Clock.runFor method

Async method available since v1.45. Advances the clock, firing all the time-related callbacks. Takes parameter 'ticks' of type long or string with the same format options as Clock.fastForward.

Clock.pauseAt method

Async method available since v1.45. Advances the clock by jumping forward in time and pauses it. Once called, no timers are fired unless Clock.runFor, Clock.fastForward, Clock.pauseAt, or Clock.resume is called. Only fires due timers at most once. This is equivalent to user closing the laptop lid for a while and reopening it at the specified time and pausing.

Clock.pauseAt best practice

For best results, install the clock before navigating the page and set it to a time slightly before the intended test time. This ensures that all timers run normally during page loading, preventing the page from getting stuck. Once the page has fully loaded, you can safely use Clock.pauseAt to pause the clock.

Clock.pauseAt time parameter for JavaScript and Java

The 'time' parameter for Clock.pauseAt in JavaScript and Java languages is of type long, string, or Date. It specifies the time to pause at.

Clock.pauseAt time parameter for Python

The 'time' parameter for Clock.pauseAt in Python is of type float, string, or Date. Numeric values are Unix time in seconds. It specifies the time to pause at.

Clock.pauseAt time parameter for C#

The 'time' parameter for Clock.pauseAt in C# is of type Date or string. It specifies the time to pause at.

Clock.setFixedTime method

Async method available since v1.45. Makes Date.now and new Date() return fixed fake time at all times while keeping all timers running. Use this method for simple scenarios where you only need to test with a predefined time. For more advanced scenarios, use Clock.install instead.

Clock.setSystemTime method

Async method available since v1.45. Sets system time but does not trigger any timers. Use this to test how the web page reacts to a time shift, for example switching from summer to winter time, or changing time zones.

Clock.setSystemTime time parameter for JavaScript and Java

The 'time' parameter for Clock.setSystemTime in JavaScript and Java languages is of type long, string, or Date. It specifies the time to be set in milliseconds.

Clock.setSystemTime time parameter for Python

The 'time' parameter for Clock.setSystemTime in Python is of type float, string, or Date. Numeric values are Unix time in seconds. It specifies the time to be set.

Clock.setSystemTime time parameter for C#

The 'time' parameter for Clock.setSystemTime in C# is of type string or Date. It specifies the time to be set.

Clock.install example with page loading

Example showing Clock.install followed by page navigation and Clock.pauseAt: Initialize clock with time before test time and let page load naturally. Date.now will progress as timers fire. After page fully loads, use pauseAt to pause the clock. JavaScript: `await page.clock.install({ time: new Date('2024-12-10T08:00:00') }); await page.goto('http://localhost:3333'); await page.clock.pauseAt(new Date('2024-12-10T10:00:00'));`

Give your agent this brain