@vitest/browser 4.0.0-beta.3 → 4.0.0-beta.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/context.d.ts +123 -0
- package/dist/client/__vitest__/assets/index-YGltZS-e.js +57 -0
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client.js +24 -8
- package/dist/expect-element.js +3 -2
- package/dist/{index-W1MM53zC.js → index-D_g_FMM5.js} +1 -1
- package/dist/index.d.ts +9 -0
- package/dist/index.js +507 -39
- package/dist/locators/index.js +1 -1
- package/dist/locators/playwright.js +1 -1
- package/dist/locators/preview.js +1 -1
- package/dist/locators/webdriverio.js +1 -1
- package/dist/providers.js +1 -1
- package/dist/shared/screenshotMatcher/types.d.ts +13 -0
- package/dist/{webdriver-KA1WiV0q.js → webdriver-AHRa6U3j.js} +21 -11
- package/jest-dom.d.ts +48 -0
- package/package.json +13 -10
- package/providers/playwright.d.ts +13 -0
- package/providers/webdriverio.d.ts +13 -0
- package/dist/client/__vitest__/assets/index-DYFYwZ2-.js +0 -57
package/context.d.ts
CHANGED
|
@@ -44,6 +44,129 @@ export interface ScreenshotOptions {
|
|
|
44
44
|
save?: boolean
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
+
export interface ScreenshotComparatorRegistry {
|
|
48
|
+
pixelmatch: {
|
|
49
|
+
/**
|
|
50
|
+
* The maximum number of pixels that are allowed to differ between the captured
|
|
51
|
+
* screenshot and the stored reference image.
|
|
52
|
+
*
|
|
53
|
+
* If set to `undefined`, any non-zero difference will cause the test to fail.
|
|
54
|
+
*
|
|
55
|
+
* For example, `allowedMismatchedPixels: 10` means the test will pass if 10
|
|
56
|
+
* or fewer pixels differ, but fail if 11 or more differ.
|
|
57
|
+
*
|
|
58
|
+
* If both this and `allowedMismatchedPixelRatio` are set, the more restrictive
|
|
59
|
+
* value (i.e., fewer allowed mismatches) will be used.
|
|
60
|
+
*
|
|
61
|
+
* @default undefined
|
|
62
|
+
*/
|
|
63
|
+
allowedMismatchedPixels?: number | undefined
|
|
64
|
+
/**
|
|
65
|
+
* The maximum allowed ratio of differing pixels between the captured screenshot
|
|
66
|
+
* and the reference image.
|
|
67
|
+
*
|
|
68
|
+
* Must be a value between `0` and `1`.
|
|
69
|
+
*
|
|
70
|
+
* For example, `allowedMismatchedPixelRatio: 0.02` means the test will pass
|
|
71
|
+
* if up to 2% of pixels differ, but fail if more than 2% differ.
|
|
72
|
+
*
|
|
73
|
+
* If both this and `allowedMismatchedPixels` are set, the more restrictive
|
|
74
|
+
* value (i.e., fewer allowed mismatches) will be used.
|
|
75
|
+
*
|
|
76
|
+
* @default undefined
|
|
77
|
+
*/
|
|
78
|
+
allowedMismatchedPixelRatio?: number | undefined
|
|
79
|
+
/**
|
|
80
|
+
* Acceptable perceived color difference between the same pixel in two images.
|
|
81
|
+
*
|
|
82
|
+
* Value ranges from `0` (strict) to `1` (very lenient). Lower values mean
|
|
83
|
+
* small differences will be detected.
|
|
84
|
+
*
|
|
85
|
+
* The comparison uses the {@link https://en.wikipedia.org/wiki/YIQ | YIQ color space}.
|
|
86
|
+
*
|
|
87
|
+
* @default 0.1
|
|
88
|
+
*/
|
|
89
|
+
threshold?: number | undefined
|
|
90
|
+
/**
|
|
91
|
+
* If `true`, disables detection and ignoring of anti-aliased pixels.
|
|
92
|
+
*
|
|
93
|
+
* @default false
|
|
94
|
+
*/
|
|
95
|
+
includeAA?: boolean | undefined
|
|
96
|
+
/**
|
|
97
|
+
* Blending level of unchanged pixels in the diff image.
|
|
98
|
+
*
|
|
99
|
+
* Ranges from `0` (white) to `1` (original brightness).
|
|
100
|
+
*
|
|
101
|
+
* @default 0.1
|
|
102
|
+
*/
|
|
103
|
+
alpha?: number | undefined
|
|
104
|
+
/**
|
|
105
|
+
* Color used for anti-aliased pixels in the diff image.
|
|
106
|
+
*
|
|
107
|
+
* Format: `[R, G, B]`
|
|
108
|
+
*
|
|
109
|
+
* @default [255, 255, 0]
|
|
110
|
+
*/
|
|
111
|
+
aaColor?: [r: number, g: number, b: number] | undefined
|
|
112
|
+
/**
|
|
113
|
+
* Color used for differing pixels in the diff image.
|
|
114
|
+
*
|
|
115
|
+
* Format: `[R, G, B]`
|
|
116
|
+
*
|
|
117
|
+
* @default [255, 0, 0]
|
|
118
|
+
*/
|
|
119
|
+
diffColor?: [r: number, g: number, b: number] | undefined
|
|
120
|
+
/**
|
|
121
|
+
* Optional alternative color for dark-on-light differences, to help show
|
|
122
|
+
* what's added vs. removed.
|
|
123
|
+
*
|
|
124
|
+
* If not set, `diffColor` is used for all differences.
|
|
125
|
+
*
|
|
126
|
+
* Format: `[R, G, B]`
|
|
127
|
+
*
|
|
128
|
+
* @default undefined
|
|
129
|
+
*/
|
|
130
|
+
diffColorAlt?: [r: number, g: number, b: number] | undefined
|
|
131
|
+
/**
|
|
132
|
+
* If `true`, shows only the diff as a mask on a transparent background,
|
|
133
|
+
* instead of overlaying it on the original image.
|
|
134
|
+
*
|
|
135
|
+
* Anti-aliased pixels won't be shown (if detected).
|
|
136
|
+
*
|
|
137
|
+
* @default false
|
|
138
|
+
*/
|
|
139
|
+
diffMask?: boolean | undefined
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export interface ScreenshotMatcherOptions<
|
|
144
|
+
ComparatorName extends keyof ScreenshotComparatorRegistry = keyof ScreenshotComparatorRegistry
|
|
145
|
+
> {
|
|
146
|
+
/**
|
|
147
|
+
* The name of the comparator to use for visual diffing.
|
|
148
|
+
*
|
|
149
|
+
* Must be one of the keys from {@linkcode ScreenshotComparatorRegistry}.
|
|
150
|
+
*
|
|
151
|
+
* @defaultValue `'pixelmatch'`
|
|
152
|
+
*/
|
|
153
|
+
comparatorName?: ComparatorName
|
|
154
|
+
comparatorOptions?: ScreenshotComparatorRegistry[ComparatorName]
|
|
155
|
+
screenshotOptions?: Omit<
|
|
156
|
+
ScreenshotOptions,
|
|
157
|
+
'element' | 'base64' | 'path' | 'save' | 'type'
|
|
158
|
+
>
|
|
159
|
+
/**
|
|
160
|
+
* Time to wait until a stable screenshot is found.
|
|
161
|
+
*
|
|
162
|
+
* Setting this value to `0` disables the timeout, but if a stable screenshot
|
|
163
|
+
* can't be determined the process will not end.
|
|
164
|
+
*
|
|
165
|
+
* @default 5000
|
|
166
|
+
*/
|
|
167
|
+
timeout?: number
|
|
168
|
+
}
|
|
169
|
+
|
|
47
170
|
export interface BrowserCommands {
|
|
48
171
|
readFile: (
|
|
49
172
|
path: string,
|