Skip to content

Commit

Permalink
fix(clock): amend setSystemTime docs (#32901)
Browse files Browse the repository at this point in the history
As discussed yesterday over
#32807. Adds some words to
differentiate `setSystemTime` from `setFixedTime`.

---------

Signed-off-by: Simon Knott <info@simonknott.de>
Co-authored-by: Dmitry Gozman <dgozman@gmail.com>
  • Loading branch information
Skn0tt and dgozman authored Oct 7, 2024
1 parent e6afb65 commit d3fbf1a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 3 additions & 1 deletion docs/src/api/class-clock.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ Resumes timers. Once this method is called, time resumes flowing, timers are fir
Makes `Date.now` and `new Date()` return fixed fake time at all times,
keeps all the timers running.

Use this method for simple scenarios where you only need to test with a predefined time. For more advanced scenarios, use [`method: Clock.install`] instead. Read docs on [clock emulation](../clock.md) to learn more.

**Usage**

```js
Expand Down Expand Up @@ -249,7 +251,7 @@ Time to be set.
## async method: Clock.setSystemTime
* since: v1.45

Sets current system time but does not trigger any timers.
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.

**Usage**

Expand Down
7 changes: 6 additions & 1 deletion packages/playwright-core/types/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18544,6 +18544,10 @@ export interface Clock {
/**
* Makes `Date.now` and `new Date()` return fixed fake time at all times, keeps all the 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([options])](https://playwright.dev/docs/api/class-clock#clock-install) instead. Read
* docs on [clock emulation](https://playwright.dev/docs/clock) to learn more.
*
* **Usage**
*
* ```js
Expand All @@ -18557,7 +18561,8 @@ export interface Clock {
setFixedTime(time: number|string|Date): Promise<void>;

/**
* Sets current system time but does not trigger any timers.
* 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.
*
* **Usage**
*
Expand Down

0 comments on commit d3fbf1a

Please sign in to comment.