diff --git a/dotnet/docs/clock.mdx b/dotnet/docs/clock.mdx index db35dbfa0f..781d913d9f 100644 --- a/dotnet/docs/clock.mdx +++ b/dotnet/docs/clock.mdx @@ -6,21 +6,26 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +import LiteYouTube from '@site/src/components/LiteYouTube'; + ## Introduction Accurately simulating time-dependent behavior is essential for verifying the correctness of applications. Utilizing [Clock] functionality allows developers to manipulate and control time within tests, enabling the precise validation of features such as rendering time, timeouts, scheduled tasks without the delays and variability of real-time execution. -[Page.Clock](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: -- `Date` -- `setTimeout` -- `clearTimeout` -- `setInterval` -- `clearInterval` -- `requestAnimationFrame` -- `cancelAnimationFrame` -- `requestIdleCallback` -- `cancelIdleCallback` -- `performance` +The [Clock] API provides the following methods to control time: +- `setFixedTime`: Sets the fixed time for `Date.now()` and `new Date()`. +- `install`: initializes the clock and allows you to: + - `pauseAt`: Pauses the time at a specific time. + - `fastForward`: Fast forwards the time. + - `runFor`: Runs the time for a specific duration. + - `resume`: Resumes the time. +- `setSystemTime`: Sets the current system time. + +The recommended approach is to use `setFixedTime` to set the time to a specific value. If that doesn't work for your use case, you can use `install` which allows you to pause time later on, fast forward it, tick it, etc. `setSystemTime` is only recommended for advanced use cases. + +:::note +[Page.Clock](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: - `Date` - `setTimeout` - `clearTimeout` - `setInterval` - `clearInterval` - `requestAnimationFrame` - `cancelAnimationFrame` - `requestIdleCallback` - `cancelIdleCallback` - `performance` +::: ## Test with predefined time @@ -129,6 +134,10 @@ await Page.Clock.RunForAsync(2000); await Expect(locator).ToHaveTextAsync("2/2/2024, 10:00:02 AM"); ``` +## Related Videos + + + [Accessibility]: /api/class-accessibility.mdx "Accessibility" [APIRequest]: /api/class-apirequest.mdx "APIRequest" diff --git a/java/docs/clock.mdx b/java/docs/clock.mdx index f1e1a65646..8c9a1315d1 100644 --- a/java/docs/clock.mdx +++ b/java/docs/clock.mdx @@ -6,21 +6,26 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +import LiteYouTube from '@site/src/components/LiteYouTube'; + ## Introduction Accurately simulating time-dependent behavior is essential for verifying the correctness of applications. Utilizing [Clock] functionality allows developers to manipulate and control time within tests, enabling the precise validation of features such as rendering time, timeouts, scheduled tasks without the delays and variability of real-time execution. -[Page.clock()](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: -- `Date` -- `setTimeout` -- `clearTimeout` -- `setInterval` -- `clearInterval` -- `requestAnimationFrame` -- `cancelAnimationFrame` -- `requestIdleCallback` -- `cancelIdleCallback` -- `performance` +The [Clock] API provides the following methods to control time: +- `setFixedTime`: Sets the fixed time for `Date.now()` and `new Date()`. +- `install`: initializes the clock and allows you to: + - `pauseAt`: Pauses the time at a specific time. + - `fastForward`: Fast forwards the time. + - `runFor`: Runs the time for a specific duration. + - `resume`: Resumes the time. +- `setSystemTime`: Sets the current system time. + +The recommended approach is to use `setFixedTime` to set the time to a specific value. If that doesn't work for your use case, you can use `install` which allows you to pause time later on, fast forward it, tick it, etc. `setSystemTime` is only recommended for advanced use cases. + +:::note +[Page.clock()](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: - `Date` - `setTimeout` - `clearTimeout` - `setInterval` - `clearInterval` - `requestAnimationFrame` - `cancelAnimationFrame` - `requestIdleCallback` - `cancelIdleCallback` - `performance` +::: ## Test with predefined time @@ -128,6 +133,10 @@ page.clock().runFor(2000); assertThat(locator).hasText("2/2/2024, 10:00:02 AM"); ``` +## Related Videos + + + [APIRequest]: /api/class-apirequest.mdx "APIRequest" [APIRequestContext]: /api/class-apirequestcontext.mdx "APIRequestContext" diff --git a/nodejs/docs/clock.mdx b/nodejs/docs/clock.mdx index 86bf038e13..190e8c8f33 100644 --- a/nodejs/docs/clock.mdx +++ b/nodejs/docs/clock.mdx @@ -6,21 +6,26 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +import LiteYouTube from '@site/src/components/LiteYouTube'; + ## Introduction Accurately simulating time-dependent behavior is essential for verifying the correctness of applications. Utilizing [Clock] functionality allows developers to manipulate and control time within tests, enabling the precise validation of features such as rendering time, timeouts, scheduled tasks without the delays and variability of real-time execution. -[page.clock](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: -- `Date` -- `setTimeout` -- `clearTimeout` -- `setInterval` -- `clearInterval` -- `requestAnimationFrame` -- `cancelAnimationFrame` -- `requestIdleCallback` -- `cancelIdleCallback` -- `performance` +The [Clock] API provides the following methods to control time: +- `setFixedTime`: Sets the fixed time for `Date.now()` and `new Date()`. +- `install`: initializes the clock and allows you to: + - `pauseAt`: Pauses the time at a specific time. + - `fastForward`: Fast forwards the time. + - `runFor`: Runs the time for a specific duration. + - `resume`: Resumes the time. +- `setSystemTime`: Sets the current system time. + +The recommended approach is to use `setFixedTime` to set the time to a specific value. If that doesn't work for your use case, you can use `install` which allows you to pause time later on, fast forward it, tick it, etc. `setSystemTime` is only recommended for advanced use cases. + +:::note +[page.clock](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: - `Date` - `setTimeout` - `clearTimeout` - `setInterval` - `clearInterval` - `requestAnimationFrame` - `cancelAnimationFrame` - `requestIdleCallback` - `cancelIdleCallback` - `performance` +::: ## Test with predefined time @@ -131,6 +136,10 @@ await page.clock.runFor(2000); await expect(page.getByTestId('current-time')).toHaveText('2/2/2024, 10:00:02 AM'); ``` +## Related Videos + + + [Accessibility]: /api/class-accessibility.mdx "Accessibility" [Android]: /api/class-android.mdx "Android" diff --git a/nodejs/docs/release-notes.mdx b/nodejs/docs/release-notes.mdx index 83f9e40e01..8afaa22444 100644 --- a/nodejs/docs/release-notes.mdx +++ b/nodejs/docs/release-notes.mdx @@ -11,6 +11,8 @@ import LiteYouTube from '@site/src/components/LiteYouTube'; ## Version 1.45 + + ### Clock Utilizing the new [Clock] API allows to manipulate and control time within tests to verify time-related behavior. This API covers many common scenarios, including: diff --git a/python/docs/clock.mdx b/python/docs/clock.mdx index 71480ed93e..a8cb401ed1 100644 --- a/python/docs/clock.mdx +++ b/python/docs/clock.mdx @@ -6,21 +6,26 @@ import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard'; +import LiteYouTube from '@site/src/components/LiteYouTube'; + ## Introduction Accurately simulating time-dependent behavior is essential for verifying the correctness of applications. Utilizing [Clock] functionality allows developers to manipulate and control time within tests, enabling the precise validation of features such as rendering time, timeouts, scheduled tasks without the delays and variability of real-time execution. -[page.clock](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: -- `Date` -- `setTimeout` -- `clearTimeout` -- `setInterval` -- `clearInterval` -- `requestAnimationFrame` -- `cancelAnimationFrame` -- `requestIdleCallback` -- `cancelIdleCallback` -- `performance` +The [Clock] API provides the following methods to control time: +- `setFixedTime`: Sets the fixed time for `Date.now()` and `new Date()`. +- `install`: initializes the clock and allows you to: + - `pauseAt`: Pauses the time at a specific time. + - `fastForward`: Fast forwards the time. + - `runFor`: Runs the time for a specific duration. + - `resume`: Resumes the time. +- `setSystemTime`: Sets the current system time. + +The recommended approach is to use `setFixedTime` to set the time to a specific value. If that doesn't work for your use case, you can use `install` which allows you to pause time later on, fast forward it, tick it, etc. `setSystemTime` is only recommended for advanced use cases. + +:::note +[page.clock](/api/class-page.mdx#page-clock) overrides native global classes and functions related to time allowing them to be manually controlled: - `Date` - `setTimeout` - `clearTimeout` - `setInterval` - `clearInterval` - `requestAnimationFrame` - `cancelAnimationFrame` - `requestIdleCallback` - `cancelIdleCallback` - `performance` +::: ## Test with predefined time @@ -225,6 +230,10 @@ await expect(locator).to_have_text("2/2/2024, 10:00:02 AM") +## Related Videos + + + [Accessibility]: /api/class-accessibility.mdx "Accessibility" [APIRequest]: /api/class-apirequest.mdx "APIRequest"