@vitest/browser 4.0.0-beta.3 → 4.0.0-beta.5

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 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,
@@ -1,24 +1,24 @@
1
1
  {
2
- "_utils-BNwnRrZR.js": {
3
- "file": "__vitest_browser__/utils-BNwnRrZR.js",
2
+ "_utils-FY_Qin7d.js": {
3
+ "file": "__vitest_browser__/utils-FY_Qin7d.js",
4
4
  "name": "utils"
5
5
  },
6
6
  "orchestrator.html": {
7
- "file": "__vitest_browser__/orchestrator-BXzaDpYw.js",
7
+ "file": "__vitest_browser__/orchestrator-CmUsRING.js",
8
8
  "name": "orchestrator",
9
9
  "src": "orchestrator.html",
10
10
  "isEntry": true,
11
11
  "imports": [
12
- "_utils-BNwnRrZR.js"
12
+ "_utils-FY_Qin7d.js"
13
13
  ]
14
14
  },
15
15
  "tester/tester.html": {
16
- "file": "__vitest_browser__/tester-DabNvcOf.js",
16
+ "file": "__vitest_browser__/tester-1ooObZUu.js",
17
17
  "name": "tester",
18
18
  "src": "tester/tester.html",
19
19
  "isEntry": true,
20
20
  "imports": [
21
- "_utils-BNwnRrZR.js"
21
+ "_utils-FY_Qin7d.js"
22
22
  ]
23
23
  }
24
24
  }