From a1a46595e1531e8b363d24cf2721bd7be064fc57 Mon Sep 17 00:00:00 2001 From: Max Schmitt Date: Mon, 16 May 2022 22:12:55 +0300 Subject: [PATCH] chore: fix wrong toHaveScreenshot defaults in docs --- docs/src/api/class-locatorassertions.md | 10 ++++--- docs/src/api/class-pageassertions.md | 8 ++--- docs/src/api/params.md | 20 ++++++++++++- packages/playwright-core/types/types.d.ts | 12 ++++++-- packages/playwright-test/types/test.d.ts | 24 ++++++++++----- tests/config/experimental.d.ts | 36 ++++++++++++++++------- 6 files changed, 79 insertions(+), 31 deletions(-) diff --git a/docs/src/api/class-locatorassertions.md b/docs/src/api/class-locatorassertions.md index df22b9d46b73b..2a39c68239dea 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 4e6fc70a0fbbc..0644419eda682 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 a62988ac7b5a4..3b3bf57fccab1 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 b0996602f6941..39b47d065f620 100644 --- a/packages/playwright-core/types/types.d.ts +++ b/packages/playwright-core/types/types.d.ts @@ -8202,7 +8202,9 @@ export interface ElementHandle extends JSHandle { /** * 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 c7e1e050d1d26..809ed98432fa1 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 c1355b05ad92c..b66d8f6d6f41b 100644 --- a/tests/config/experimental.d.ts +++ b/tests/config/experimental.d.ts @@ -8204,7 +8204,9 @@ export interface ElementHandle extends JSHandle { /** * 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";