@vitest/browser 4.0.13 → 4.0.15
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 +19 -0
- package/dist/client/.vite/manifest.json +1 -1
- package/dist/client/__vitest__/assets/index-CfDzoXo3.js +57 -0
- package/dist/client/__vitest__/assets/index-DlhE0rqZ.css +1 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/{tester-gw0ZBXrK.js → tester-CrGChK3u.js} +1 -0
- package/dist/client/tester/tester.html +1 -1
- package/dist/context.js +11 -2
- package/dist/expect-element.js +3 -3
- package/dist/{index-hFpxawnd.js → index-CEutxZap.js} +1 -1
- package/dist/index.js +30 -10
- package/dist/locators.js +1 -1
- package/dist/shared/screenshotMatcher/types.d.ts +8 -2
- package/package.json +6 -6
- package/dist/client/__vitest__/assets/index-TGTX-jRo.js +0 -57
- package/dist/client/__vitest__/assets/index-VPnwgb7M.css +0 -1
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { PNG } from 'pngjs';
|
|
|
18
18
|
import pm from 'pixelmatch';
|
|
19
19
|
import { WebSocketServer } from 'ws';
|
|
20
20
|
|
|
21
|
-
var version = "4.0.
|
|
21
|
+
var version = "4.0.15";
|
|
22
22
|
|
|
23
23
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
24
24
|
function normalizeWindowsPath(input = "") {
|
|
@@ -1376,7 +1376,7 @@ body {
|
|
|
1376
1376
|
});
|
|
1377
1377
|
}
|
|
1378
1378
|
};
|
|
1379
|
-
return { optimizeDeps: rolldownVersion ? {
|
|
1379
|
+
return { optimizeDeps: rolldownVersion ? { rolldownOptions: { plugins: [rolldownPlugin] } } : { esbuildOptions: { plugins: [esbuildPlugin] } } };
|
|
1380
1380
|
}
|
|
1381
1381
|
}
|
|
1382
1382
|
];
|
|
@@ -2248,7 +2248,11 @@ const screenshotMatcher = async (context, name, testName, options) => {
|
|
|
2248
2248
|
if (value === null || value.actual === null) {
|
|
2249
2249
|
return {
|
|
2250
2250
|
pass: false,
|
|
2251
|
-
reference: referenceFile &&
|
|
2251
|
+
reference: referenceFile && {
|
|
2252
|
+
path: paths.reference,
|
|
2253
|
+
width: reference.metadata.width,
|
|
2254
|
+
height: reference.metadata.height
|
|
2255
|
+
},
|
|
2252
2256
|
actual: null,
|
|
2253
2257
|
diff: null,
|
|
2254
2258
|
message: `Could not capture a stable screenshot within ${timeout}ms.`
|
|
@@ -2266,7 +2270,11 @@ const screenshotMatcher = async (context, name, testName, options) => {
|
|
|
2266
2270
|
if (updateSnapshot !== "all") {
|
|
2267
2271
|
return {
|
|
2268
2272
|
pass: false,
|
|
2269
|
-
reference:
|
|
2273
|
+
reference: {
|
|
2274
|
+
path: referencePath,
|
|
2275
|
+
width: value.actual.metadata.width,
|
|
2276
|
+
height: value.actual.metadata.height
|
|
2277
|
+
},
|
|
2270
2278
|
actual: null,
|
|
2271
2279
|
diff: null,
|
|
2272
2280
|
message: `No existing reference screenshot found${shouldCreateReference ? "; a new one was created. Review it before running tests again." : "."}`
|
|
@@ -2310,8 +2318,16 @@ const screenshotMatcher = async (context, name, testName, options) => {
|
|
|
2310
2318
|
// - fail
|
|
2311
2319
|
return {
|
|
2312
2320
|
pass: false,
|
|
2313
|
-
reference:
|
|
2314
|
-
|
|
2321
|
+
reference: {
|
|
2322
|
+
path: paths.reference,
|
|
2323
|
+
width: reference.metadata.width,
|
|
2324
|
+
height: reference.metadata.height
|
|
2325
|
+
},
|
|
2326
|
+
actual: {
|
|
2327
|
+
path: paths.diffs.actual,
|
|
2328
|
+
width: value.actual.metadata.width,
|
|
2329
|
+
height: value.actual.metadata.height
|
|
2330
|
+
},
|
|
2315
2331
|
diff: finalResult.diff && paths.diffs.diff,
|
|
2316
2332
|
message: `Screenshot does not match the stored reference.${finalResult.message === null ? "" : `\n${finalResult.message}`}`
|
|
2317
2333
|
};
|
|
@@ -2442,8 +2458,8 @@ class ProjectBrowser {
|
|
|
2442
2458
|
if (this.provider.initScripts) {
|
|
2443
2459
|
this.parent.initScripts = this.provider.initScripts;
|
|
2444
2460
|
// make sure the script can be imported
|
|
2461
|
+
const allow = this.parent.vite.config.server.fs.allow;
|
|
2445
2462
|
this.provider.initScripts.forEach((script) => {
|
|
2446
|
-
const allow = this.parent.vite.config.server.fs.allow;
|
|
2447
2463
|
if (!allow.includes(script)) {
|
|
2448
2464
|
allow.push(script);
|
|
2449
2465
|
}
|
|
@@ -2927,13 +2943,14 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
2927
2943
|
}
|
|
2928
2944
|
wss.handleUpgrade(request, socket, head, (ws) => {
|
|
2929
2945
|
wss.emit("connection", ws, request);
|
|
2930
|
-
const rpc = setupClient(project, rpcId, ws);
|
|
2946
|
+
const { rpc, offCancel } = setupClient(project, rpcId, ws);
|
|
2931
2947
|
const state = project.browser.state;
|
|
2932
2948
|
const clients = type === "tester" ? state.testers : state.orchestrators;
|
|
2933
2949
|
clients.set(rpcId, rpc);
|
|
2934
2950
|
debug?.("[%s] Browser API connected to %s", rpcId, type);
|
|
2935
2951
|
ws.on("close", () => {
|
|
2936
2952
|
debug?.("[%s] Browser API disconnected from %s", rpcId, type);
|
|
2953
|
+
offCancel();
|
|
2937
2954
|
clients.delete(rpcId);
|
|
2938
2955
|
globalServer.removeCDPHandler(rpcId);
|
|
2939
2956
|
if (type === "orchestrator") {
|
|
@@ -3164,8 +3181,11 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
3164
3181
|
deserialize: parse,
|
|
3165
3182
|
timeout: -1
|
|
3166
3183
|
});
|
|
3167
|
-
vitest.onCancel((reason) => rpc.onCancel(reason));
|
|
3168
|
-
return
|
|
3184
|
+
const offCancel = vitest.onCancel((reason) => rpc.onCancel(reason));
|
|
3185
|
+
return {
|
|
3186
|
+
rpc,
|
|
3187
|
+
offCancel
|
|
3188
|
+
};
|
|
3169
3189
|
}
|
|
3170
3190
|
}
|
|
3171
3191
|
function retrieveSourceMapURL(source) {
|
package/dist/locators.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export{L as Locator,
|
|
1
|
+
export{L as Locator,n as convertElementToCssSelector,q as getByAltTextSelector,r as getByLabelSelector,t as getByPlaceholderSelector,u as getByRoleSelector,v as getByTestIdSelector,w as getByTextSelector,x as getByTitleSelector,o as getIframeScale,p as processTimeoutOptions,s as selectorEngine}from"./index-CEutxZap.js";import"vitest/browser";import"vitest/internal/browser";
|
|
@@ -5,12 +5,18 @@ export type ScreenshotMatcherArguments<ComparatorName extends keyof ScreenshotCo
|
|
|
5
5
|
mask?: readonly string[];
|
|
6
6
|
};
|
|
7
7
|
}];
|
|
8
|
+
interface ScreenshotData {
|
|
9
|
+
path: string;
|
|
10
|
+
width: number;
|
|
11
|
+
height: number;
|
|
12
|
+
}
|
|
8
13
|
export type ScreenshotMatcherOutput = Promise<{
|
|
9
14
|
pass: false;
|
|
10
|
-
reference:
|
|
11
|
-
actual:
|
|
15
|
+
reference: ScreenshotData | null;
|
|
16
|
+
actual: ScreenshotData | null;
|
|
12
17
|
diff: string | null;
|
|
13
18
|
message: string;
|
|
14
19
|
} | {
|
|
15
20
|
pass: true;
|
|
16
21
|
}>;
|
|
22
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.15",
|
|
5
5
|
"description": "Browser running for Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -51,7 +51,7 @@
|
|
|
51
51
|
"providers"
|
|
52
52
|
],
|
|
53
53
|
"peerDependencies": {
|
|
54
|
-
"vitest": "4.0.
|
|
54
|
+
"vitest": "4.0.15"
|
|
55
55
|
},
|
|
56
56
|
"dependencies": {
|
|
57
57
|
"magic-string": "^0.30.21",
|
|
@@ -60,8 +60,8 @@
|
|
|
60
60
|
"sirv": "^3.0.2",
|
|
61
61
|
"tinyrainbow": "^3.0.3",
|
|
62
62
|
"ws": "^8.18.3",
|
|
63
|
-
"@vitest/mocker": "4.0.
|
|
64
|
-
"@vitest/utils": "4.0.
|
|
63
|
+
"@vitest/mocker": "4.0.15",
|
|
64
|
+
"@vitest/utils": "4.0.15"
|
|
65
65
|
},
|
|
66
66
|
"devDependencies": {
|
|
67
67
|
"@testing-library/user-event": "^14.6.1",
|
|
@@ -72,8 +72,8 @@
|
|
|
72
72
|
"ivya": "^1.7.0",
|
|
73
73
|
"mime": "^4.1.0",
|
|
74
74
|
"pathe": "^2.0.3",
|
|
75
|
-
"@vitest/runner": "4.0.
|
|
76
|
-
"vitest": "4.0.
|
|
75
|
+
"@vitest/runner": "4.0.15",
|
|
76
|
+
"vitest": "4.0.15"
|
|
77
77
|
},
|
|
78
78
|
"scripts": {
|
|
79
79
|
"typecheck": "tsc -p ./src/client/tsconfig.json --noEmit",
|