fix: support all commong screenshot options in toHaveScreenshot (#12670)

This patch adds support for all common options in
`expect.toHaveScreenshot`.
This commit is contained in:
Andrey Lushnikov 2022-03-10 19:36:20 -07:00 committed by GitHub
parent 65b9cba143
commit e83549e8a0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 47 additions and 71 deletions

View file

@ -1501,10 +1501,12 @@ export type PageExpectScreenshotParams = {
threshold?: number, threshold?: number,
}, },
screenshotOptions?: { screenshotOptions?: {
omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
omitBackground?: boolean,
animations?: 'disabled' | 'allow',
size?: 'css' | 'device',
fonts?: 'ready' | 'nowait',
mask?: { mask?: {
frame: FrameChannel, frame: FrameChannel,
selector: string, selector: string,
@ -1524,10 +1526,12 @@ export type PageExpectScreenshotOptions = {
threshold?: number, threshold?: number,
}, },
screenshotOptions?: { screenshotOptions?: {
omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
omitBackground?: boolean,
animations?: 'disabled' | 'allow',
size?: 'css' | 'device',
fonts?: 'ready' | 'nowait',
mask?: { mask?: {
frame: FrameChannel, frame: FrameChannel,
selector: string, selector: string,
@ -1545,10 +1549,10 @@ export type PageScreenshotParams = {
timeout?: number, timeout?: number,
type?: 'png' | 'jpeg', type?: 'png' | 'jpeg',
quality?: number, quality?: number,
omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
omitBackground?: boolean,
animations?: 'disabled' | 'allow',
size?: 'css' | 'device', size?: 'css' | 'device',
fonts?: 'ready' | 'nowait', fonts?: 'ready' | 'nowait',
mask?: { mask?: {
@ -1560,10 +1564,10 @@ export type PageScreenshotOptions = {
timeout?: number, timeout?: number,
type?: 'png' | 'jpeg', type?: 'png' | 'jpeg',
quality?: number, quality?: number,
omitBackground?: boolean,
fullPage?: boolean, fullPage?: boolean,
animations?: 'disabled' | 'allow',
clip?: Rect, clip?: Rect,
omitBackground?: boolean,
animations?: 'disabled' | 'allow',
size?: 'css' | 'device', size?: 'css' | 'device',
fonts?: 'ready' | 'nowait', fonts?: 'ready' | 'nowait',
mask?: { mask?: {

View file

@ -309,6 +309,32 @@ LifecycleEvent:
- networkidle - networkidle
- commit - commit
CommonScreenshotOptions:
type: mixin
properties:
omitBackground: boolean?
animations:
type: enum?
literals:
- disabled
- allow
size:
type: enum?
literals:
- css
- device
fonts:
type: enum?
literals:
- ready
- nowait
mask:
type: array?
items:
type: object
properties:
frame: Frame
selector: string
LaunchOptions: LaunchOptions:
type: mixin type: mixin
@ -1009,21 +1035,9 @@ Page:
screenshotOptions: screenshotOptions:
type: object? type: object?
properties: properties:
omitBackground: boolean?
fullPage: boolean? fullPage: boolean?
animations:
type: enum?
literals:
- disabled
- allow
clip: Rect? clip: Rect?
mask: $mixin: CommonScreenshotOptions
type: array?
items:
type: object
properties:
frame: Frame
selector: string
returns: returns:
diff: binary? diff: binary?
errorMessage: string? errorMessage: string?
@ -1044,31 +1058,9 @@ Page:
- png - png
- jpeg - jpeg
quality: number? quality: number?
omitBackground: boolean?
fullPage: boolean? fullPage: boolean?
animations:
type: enum?
literals:
- disabled
- allow
clip: Rect? clip: Rect?
size: $mixin: CommonScreenshotOptions
type: enum?
literals:
- css
- device
fonts:
type: enum?
literals:
- ready
- nowait
mask:
type: array?
items:
type: object
properties:
frame: Frame
selector: string
returns: returns:
binary: binary binary: binary
tracing: tracing:
@ -2221,29 +2213,7 @@ ElementHandle:
- png - png
- jpeg - jpeg
quality: number? quality: number?
omitBackground: boolean? $mixin: CommonScreenshotOptions
animations:
type: enum?
literals:
- disabled
- allow
size:
type: enum?
literals:
- css
- device
fonts:
type: enum?
literals:
- ready
- nowait
mask:
type: array?
items:
type: object
properties:
frame: Frame
selector: string
returns: returns:
binary: binary binary: binary
tracing: tracing:

View file

@ -554,10 +554,12 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
threshold: tOptional(tNumber), threshold: tOptional(tNumber),
})), })),
screenshotOptions: tOptional(tObject({ screenshotOptions: tOptional(tObject({
omitBackground: tOptional(tBoolean),
fullPage: tOptional(tBoolean), fullPage: tOptional(tBoolean),
animations: tOptional(tEnum(['disabled', 'allow'])),
clip: tOptional(tType('Rect')), clip: tOptional(tType('Rect')),
omitBackground: tOptional(tBoolean),
animations: tOptional(tEnum(['disabled', 'allow'])),
size: tOptional(tEnum(['css', 'device'])),
fonts: tOptional(tEnum(['ready', 'nowait'])),
mask: tOptional(tArray(tObject({ mask: tOptional(tArray(tObject({
frame: tChannel('Frame'), frame: tChannel('Frame'),
selector: tString, selector: tString,
@ -568,10 +570,10 @@ export function createScheme(tChannel: (name: string) => Validator): Scheme {
timeout: tOptional(tNumber), timeout: tOptional(tNumber),
type: tOptional(tEnum(['png', 'jpeg'])), type: tOptional(tEnum(['png', 'jpeg'])),
quality: tOptional(tNumber), quality: tOptional(tNumber),
omitBackground: tOptional(tBoolean),
fullPage: tOptional(tBoolean), fullPage: tOptional(tBoolean),
animations: tOptional(tEnum(['disabled', 'allow'])),
clip: tOptional(tType('Rect')), clip: tOptional(tType('Rect')),
omitBackground: tOptional(tBoolean),
animations: tOptional(tEnum(['disabled', 'allow'])),
size: tOptional(tEnum(['css', 'device'])), size: tOptional(tEnum(['css', 'device'])),
fonts: tOptional(tEnum(['ready', 'nowait'])), fonts: tOptional(tEnum(['ready', 'nowait'])),
mask: tOptional(tArray(tObject({ mask: tOptional(tArray(tObject({