-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmatchScreenshot.ts
More file actions
89 lines (81 loc) · 2.16 KB
/
matchScreenshot.ts
File metadata and controls
89 lines (81 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
import type {Brand} from './brand';
import type {Url} from './http';
import type {RunLabel} from './runLabel';
import type {Selector} from './selectors';
import type {TestStaticOptions} from './testRun';
import type {TestMetaPlaceholder} from './userland';
/**
* Dimensions of screenshot image.
*/
export type Dimensions = Readonly<{
height: number;
width: number;
}>;
/**
* String with dimensions of screenshot, like `320x108`.
*/
export type DimensionsString = Brand<string, 'DimensionsString'>;
/**
* Functions that describe the `toMatchScreenshot` assert (in `expect`).
*/
export type MatchScreenshotConfig<TestMeta = TestMetaPlaceholder> = Readonly<{
/**
* Get url to screenshot (for using in web-interfaces) by `screenshotId`.
*/
getScreenshotUrlById: (this: void, screenshotId: string) => Url;
/**
* Reads screenshot by `screenshotId`.
*/
readScreenshot: (
this: void,
screenshotId: string,
meta: ScreenshotMeta<TestMeta>,
) => Promise<Uint8Array | undefined>;
/**
* Writes screenshot by `screenshotId` and optional context info.
*/
writeScreenshot: (
this: void,
screenshot: Uint8Array,
meta: ScreenshotMeta<TestMeta>,
) => Promise<string>;
}>;
/**
* Log fields for single screenshot.
* @internal
*/
export type ScreenshotLogFields = {
dimensions: DimensionsString;
readonly screenshotId: string;
url: Url;
};
/**
* General screenshot metadata (like test name, assert description, etc.).
*/
export type ScreenshotMeta<TestMeta = TestMetaPlaceholder> = Readonly<{
actual: string | undefined;
description: string;
expected: string | undefined;
options: ToMatchScreenshotOptions;
pageUrl: Url;
pathToPack: string;
runLabel: RunLabel;
selector: string;
testStaticOptions: TestStaticOptions<TestMeta>;
timeInMs: number;
}>;
/**
* Options for `toMatchScreenshot` assert.
*/
export type ToMatchScreenshotOptions = Readonly<{
animations?: 'allow' | 'disabled';
caret?: 'hide' | 'initial';
mask?: readonly Selector[];
maskColor?: string;
maxDiffPixelRatio?: number;
maxDiffPixels?: number;
omitBackground?: boolean;
scale?: 'css' | 'device';
threshold?: number;
timeout?: number;
}>;