Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

chore: fix wrong toHaveScreenshot defaults in docs (#14200)

Max Schmitt9256de5f484e
diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.md
index df22b9d46b..2a39c68239 100644
--- a/docs/src/api/class-locatorassertions.md
+++ b/docs/src/api/class-locatorassertions.md
@@ -1022,11 +1022,12 @@ await expect(locator).toHaveScreenshot('image.png');
Snapshot name.
### option: LocatorAssertions.toHaveScreenshot#1.timeout = %%-js-assertions-timeout-%%
-### option: LocatorAssertions.toHaveScreenshot#1.animations = %%-screenshot-option-animations-%%
+### option: LocatorAssertions.toHaveScreenshot#1.animations = %%-screenshot-option-animations-default-disabled-%%
+
### option: LocatorAssertions.toHaveScreenshot#1.caret = %%-screenshot-option-caret-%%
### option: LocatorAssertions.toHaveScreenshot#1.mask = %%-screenshot-option-mask-%%
### option: LocatorAssertions.toHaveScreenshot#1.omitBackground = %%-screenshot-option-omit-background-%%
-### option: LocatorAssertions.toHaveScreenshot#1.scale = %%-screenshot-option-scale-%%
+### option: LocatorAssertions.toHaveScreenshot#1.scale = %%-screenshot-option-scale-default-css-%%
### option: LocatorAssertions.toHaveScreenshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
### option: LocatorAssertions.toHaveScreenshot#1.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
### option: LocatorAssertions.toHaveScreenshot#1.threshold = %%-assertions-threshold-%%
@@ -1046,11 +1047,12 @@ await expect(locator).toHaveScreenshot();
```
### option: LocatorAssertions.toHaveScreenshot#2.timeout = %%-js-assertions-timeout-%%
-### option: LocatorAssertions.toHaveScreenshot#2.animations = %%-screenshot-option-animations-%%
+### option: LocatorAssertions.toHaveScreenshot#2.animations = %%-screenshot-option-animations-default-disabled-%%
+
### option: LocatorAssertions.toHaveScreenshot#2.caret = %%-screenshot-option-caret-%%
### option: LocatorAssertions.toHaveScreenshot#2.mask = %%-screenshot-option-mask-%%
### option: LocatorAssertions.toHaveScreenshot#2.omitBackground = %%-screenshot-option-omit-background-%%
-### option: LocatorAssertions.toHaveScreenshot#2.scale = %%-screenshot-option-scale-%%
+### option: LocatorAssertions.toHaveScreenshot#2.scale = %%-screenshot-option-scale-default-css-%%
### option: LocatorAssertions.toHaveScreenshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
### option: LocatorAssertions.toHaveScreenshot#2.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
### option: LocatorAssertions.toHaveScreenshot#2.threshold = %%-assertions-threshold-%%
diff --git a/docs/src/api/class-pageassertions.md b/docs/src/api/class-pageassertions.md
index 4e6fc70a0f..0644419eda 100644
--- a/docs/src/api/class-pageassertions.md
+++ b/docs/src/api/class-pageassertions.md
@@ -133,13 +133,13 @@ await expect(page).toHaveScreenshot('image.png');
Snapshot name.
### option: PageAssertions.toHaveScreenshot#1.timeout = %%-js-assertions-timeout-%%
-### option: PageAssertions.toHaveScreenshot#1.animations = %%-screenshot-option-animations-%%
+### option: PageAssertions.toHaveScreenshot#1.animations = %%-screenshot-option-animations-default-disabled-%%
### option: PageAssertions.toHaveScreenshot#1.caret = %%-screenshot-option-caret-%%
### option: PageAssertions.toHaveScreenshot#1.clip = %%-screenshot-option-clip-%%
### option: PageAssertions.toHaveScreenshot#1.fullPage = %%-screenshot-option-full-page-%%
### option: PageAssertions.toHaveScreenshot#1.mask = %%-screenshot-option-mask-%%
### option: PageAssertions.toHaveScreenshot#1.omitBackground = %%-screenshot-option-omit-background-%%
-### option: PageAssertions.toHaveScreenshot#1.scale = %%-screenshot-option-scale-%%
+### option: PageAssertions.toHaveScreenshot#1.scale = %%-screenshot-option-scale-default-css-%%
### option: PageAssertions.toHaveScreenshot#1.maxDiffPixels = %%-assertions-max-diff-pixels-%%
### option: PageAssertions.toHaveScreenshot#1.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
### option: PageAssertions.toHaveScreenshot#1.threshold = %%-assertions-threshold-%%
@@ -159,13 +159,13 @@ await expect(page).toHaveScreenshot();
```
### option: PageAssertions.toHaveScreenshot#2.timeout = %%-js-assertions-timeout-%%
-### option: PageAssertions.toHaveScreenshot#2.animations = %%-screenshot-option-animations-%%
+### option: PageAssertions.toHaveScreenshot#2.animations = %%-screenshot-option-animations-default-disabled-%%
### option: PageAssertions.toHaveScreenshot#2.caret = %%-screenshot-option-caret-%%
### option: PageAssertions.toHaveScreenshot#2.clip = %%-screenshot-option-clip-%%
### option: PageAssertions.toHaveScreenshot#2.fullPage = %%-screenshot-option-full-page-%%
### option: PageAssertions.toHaveScreenshot#2.mask = %%-screenshot-option-mask-%%
### option: PageAssertions.toHaveScreenshot#2.omitBackground = %%-screenshot-option-omit-background-%%
-### option: PageAssertions.toHaveScreenshot#2.scale = %%-screenshot-option-scale-%%
+### option: PageAssertions.toHaveScreenshot#2.scale = %%-screenshot-option-scale-default-css-%%
### option: PageAssertions.toHaveScreenshot#2.maxDiffPixels = %%-assertions-max-diff-pixels-%%
### option: PageAssertions.toHaveScreenshot#2.maxDiffPixelRatio = %%-assertions-max-diff-pixel-ratio-%%
### option: PageAssertions.toHaveScreenshot#2.threshold = %%-assertions-threshold-%%
diff --git a/docs/src/api/params.md b/docs/src/api/params.md
index a62988ac7b..3b3bf57fcc 100644
--- a/docs/src/api/params.md
+++ b/docs/src/api/params.md
@@ -910,6 +910,15 @@ When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animatio
Defaults to `"allow"` that leaves animations untouched.
+## screenshot-option-animations-default-disabled
+- `animations` <[ScreenshotAnimations]<"disabled"|"allow">>
+
+When set to `"disabled"`, stops CSS animations, CSS transitions and Web Animations. Animations get different treatment depending on their duration:
+* finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
+* infinite animations are canceled to initial state, and then played over after the screenshot.
+
+Defaults to `"disabled"` that disables animations.
+
## screenshot-option-omit-background
- `omitBackground` <[boolean]>
@@ -957,7 +966,16 @@ An object which specifies clipping of the resulting image. Should have the follo
## screenshot-option-scale
- `scale` <[ScreenshotScale]<"css"|"device">>
-When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of high-dpi devices will be twice as large or even larger.
+
+Defaults to `"device"`.
+
+## screenshot-option-scale-default-css
+- `scale` <[ScreenshotScale]<"css"|"device">>
+
+When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of high-dpi devices will be twice as large or even larger.
+
+Defaults to `"css"`.
## screenshot-option-caret
- `caret` <[ScreenshotCaret]<"hide"|"initial">>
diff --git a/packages/playwright-core/types/types.d.ts b/packages/playwright-core/types/types.d.ts
index b0996602f6..39b47d065f 100644
--- a/packages/playwright-core/types/types.d.ts
+++ b/packages/playwright-core/types/types.d.ts
@@ -8202,7 +8202,9 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"device"`.
*/
scale?: "css"|"device";
@@ -15844,7 +15846,9 @@ export interface LocatorScreenshotOptions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"device"`.
*/
scale?: "css"|"device";
@@ -16027,7 +16031,9 @@ export interface PageScreenshotOptions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"device"`.
*/
scale?: "css"|"device";
diff --git a/packages/playwright-test/types/test.d.ts b/packages/playwright-test/types/test.d.ts
index c7e1e050d1..809ed98432 100644
--- a/packages/playwright-test/types/test.d.ts
+++ b/packages/playwright-test/types/test.d.ts
@@ -3349,7 +3349,7 @@ interface LocatorAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -3386,7 +3386,9 @@ interface LocatorAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";
@@ -3424,7 +3426,7 @@ interface LocatorAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -3461,7 +3463,9 @@ interface LocatorAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";
@@ -3578,7 +3582,7 @@ interface PageAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -3646,7 +3650,9 @@ interface PageAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";
@@ -3683,7 +3689,7 @@ interface PageAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -3751,7 +3757,9 @@ interface PageAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";
diff --git a/tests/config/experimental.d.ts b/tests/config/experimental.d.ts
index c1355b05ad..b66d8f6d6f 100644
--- a/tests/config/experimental.d.ts
+++ b/tests/config/experimental.d.ts
@@ -8204,7 +8204,9 @@ export interface ElementHandle<T=Node> extends JSHandle<T> {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"device"`.
*/
scale?: "css"|"device";
@@ -15846,7 +15848,9 @@ export interface LocatorScreenshotOptions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"device"`.
*/
scale?: "css"|"device";
@@ -16029,7 +16033,9 @@ export interface PageScreenshotOptions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"device"`.
*/
scale?: "css"|"device";
@@ -19555,7 +19561,7 @@ interface LocatorAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -19592,7 +19598,9 @@ interface LocatorAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";
@@ -19630,7 +19638,7 @@ interface LocatorAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -19667,7 +19675,9 @@ interface LocatorAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";
@@ -19784,7 +19794,7 @@ interface PageAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -19852,7 +19862,9 @@ interface PageAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";
@@ -19889,7 +19901,7 @@ interface PageAssertions {
* - finite animations are fast-forwarded to completion, so they'll fire `transitionend` event.
* - infinite animations are canceled to initial state, and then played over after the screenshot.
*
- * Defaults to `"allow"` that leaves animations untouched.
+ * Defaults to `"disabled"` that disables animations.
*/
animations?: "disabled"|"allow";
@@ -19957,7 +19969,9 @@ interface PageAssertions {
/**
* When set to `"css"`, screenshot will have a single pixel per each css pixel on the page. For high-dpi devices, this will
* keep screenshots small. Using `"device"` option will produce a single pixel per each device pixel, so screenhots of
- * high-dpi devices will be twice as large or even larger. Defaults to `"device"`.
+ * high-dpi devices will be twice as large or even larger.
+ *
+ * Defaults to `"css"`.
*/
scale?: "css"|"device";