@vitest/browser 3.2.0-beta.3 → 3.2.1
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 +1 -1
- package/dist/client/.vite/manifest.json +2 -2
- package/dist/client/__vitest__/assets/{index-CVSF215x.css → index-BXfDBrdK.css} +1 -1
- package/dist/client/__vitest__/assets/index-Br0wpA4B.js +58 -0
- package/dist/client/__vitest__/index.html +2 -2
- package/dist/client/__vitest_browser__/orchestrator-R-D9fwJI.js +2724 -0
- package/dist/client/__vitest_browser__/{tester-BV-CSJ5v.js → tester-B_w3in1j.js} +53 -6
- package/dist/client/esm-client-injector.js +1 -0
- package/dist/client/orchestrator.html +1 -1
- package/dist/client/tester/tester.html +1 -1
- package/dist/client.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.js +5 -1
- package/dist/state.js +1 -0
- package/package.json +11 -11
- package/dist/client/__vitest__/assets/index-C03hLyIS.js +0 -52
- package/dist/client/__vitest_browser__/orchestrator-Bsc_nLaw.js +0 -291
|
@@ -14,12 +14,22 @@ const seen = {};
|
|
|
14
14
|
const __vitePreload = function preload(baseModule, deps, importerUrl) {
|
|
15
15
|
let promise = Promise.resolve();
|
|
16
16
|
if (deps && deps.length > 0) {
|
|
17
|
+
let allSettled2 = function(promises2) {
|
|
18
|
+
return Promise.all(
|
|
19
|
+
promises2.map(
|
|
20
|
+
(p2) => Promise.resolve(p2).then(
|
|
21
|
+
(value) => ({ status: "fulfilled", value }),
|
|
22
|
+
(reason) => ({ status: "rejected", reason })
|
|
23
|
+
)
|
|
24
|
+
)
|
|
25
|
+
);
|
|
26
|
+
};
|
|
17
27
|
document.getElementsByTagName("link");
|
|
18
28
|
const cspNonceMeta = document.querySelector(
|
|
19
29
|
"meta[property=csp-nonce]"
|
|
20
30
|
);
|
|
21
31
|
const cspNonce = (cspNonceMeta == null ? void 0 : cspNonceMeta.nonce) || (cspNonceMeta == null ? void 0 : cspNonceMeta.getAttribute("nonce"));
|
|
22
|
-
promise =
|
|
32
|
+
promise = allSettled2(
|
|
23
33
|
deps.map((dep) => {
|
|
24
34
|
dep = assetsURL(dep);
|
|
25
35
|
if (dep in seen) return;
|
|
@@ -1589,6 +1599,31 @@ function createBrowserRunner(runnerClass, mocker, state, coverageModule) {
|
|
|
1589
1599
|
}
|
|
1590
1600
|
return rpc$2().onCollected(this.method, files);
|
|
1591
1601
|
});
|
|
1602
|
+
__publicField(this, "onTestAnnotate", (test, annotation) => {
|
|
1603
|
+
if (annotation.location) {
|
|
1604
|
+
const map = this.sourceMapCache.get(annotation.location.file);
|
|
1605
|
+
if (!map) {
|
|
1606
|
+
return rpc$2().onTaskAnnotate(test.id, annotation);
|
|
1607
|
+
}
|
|
1608
|
+
const traceMap = new TraceMap(map);
|
|
1609
|
+
const { line, column, source } = originalPositionFor(traceMap, annotation.location);
|
|
1610
|
+
if (line != null && column != null && source != null) {
|
|
1611
|
+
let file = annotation.location.file;
|
|
1612
|
+
if (source) {
|
|
1613
|
+
const fileUrl = annotation.location.file.startsWith("file://") ? annotation.location.file : `file://${annotation.location.file}`;
|
|
1614
|
+
const sourceRootUrl = map.sourceRoot ? new URL(map.sourceRoot, fileUrl) : fileUrl;
|
|
1615
|
+
file = new URL(source, sourceRootUrl).pathname;
|
|
1616
|
+
}
|
|
1617
|
+
annotation.location = {
|
|
1618
|
+
line,
|
|
1619
|
+
column: column + 1,
|
|
1620
|
+
// if the file path is on windows, we need to remove the starting slash
|
|
1621
|
+
file: file.match(/\/\w:\//) ? file.slice(1) : file
|
|
1622
|
+
};
|
|
1623
|
+
}
|
|
1624
|
+
}
|
|
1625
|
+
return rpc$2().onTaskAnnotate(test.id, annotation);
|
|
1626
|
+
});
|
|
1592
1627
|
__publicField(this, "onTaskUpdate", (task, events) => {
|
|
1593
1628
|
return rpc$2().onTaskUpdate(this.method, task, events);
|
|
1594
1629
|
});
|
|
@@ -1655,14 +1690,23 @@ async function initiateRunner(state, mocker, config) {
|
|
|
1655
1690
|
};
|
|
1656
1691
|
return runner;
|
|
1657
1692
|
}
|
|
1693
|
+
async function getTraceMap(file, sourceMaps) {
|
|
1694
|
+
const result = sourceMaps.get(file) || await rpc$2().getBrowserFileSourceMap(file).then((map) => {
|
|
1695
|
+
sourceMaps.set(file, map);
|
|
1696
|
+
return map;
|
|
1697
|
+
});
|
|
1698
|
+
if (!result) {
|
|
1699
|
+
return null;
|
|
1700
|
+
}
|
|
1701
|
+
return new TraceMap(result);
|
|
1702
|
+
}
|
|
1658
1703
|
async function updateTestFilesLocations(files, sourceMaps) {
|
|
1659
1704
|
const promises2 = files.map(async (file) => {
|
|
1660
|
-
const
|
|
1661
|
-
if (!
|
|
1705
|
+
const traceMap = await getTraceMap(file.filepath, sourceMaps);
|
|
1706
|
+
if (!traceMap) {
|
|
1662
1707
|
return null;
|
|
1663
1708
|
}
|
|
1664
|
-
const
|
|
1665
|
-
function updateLocation(task) {
|
|
1709
|
+
const updateLocation = (task) => {
|
|
1666
1710
|
if (task.location) {
|
|
1667
1711
|
const { line, column } = originalPositionFor(traceMap, task.location);
|
|
1668
1712
|
if (line != null && column != null) {
|
|
@@ -1672,7 +1716,7 @@ async function updateTestFilesLocations(files, sourceMaps) {
|
|
|
1672
1716
|
if ("tasks" in task) {
|
|
1673
1717
|
task.tasks.forEach(updateLocation);
|
|
1674
1718
|
}
|
|
1675
|
-
}
|
|
1719
|
+
};
|
|
1676
1720
|
file.tasks.forEach(updateLocation);
|
|
1677
1721
|
return null;
|
|
1678
1722
|
});
|
|
@@ -3502,6 +3546,9 @@ async function cleanup() {
|
|
|
3502
3546
|
}
|
|
3503
3547
|
}
|
|
3504
3548
|
await userEvent.cleanup().catch((error) => unhandledError(error, "Cleanup Error"));
|
|
3549
|
+
await Promise.all(
|
|
3550
|
+
getBrowserState().cleanups.map((fn) => fn())
|
|
3551
|
+
).catch((error) => unhandledError(error, "Cleanup Error"));
|
|
3505
3552
|
if (contextSwitched) {
|
|
3506
3553
|
await rpc2.wdioSwitchContext("parent").catch((error) => unhandledError(error, "Cleanup Error"));
|
|
3507
3554
|
}
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
{__VITEST_INJECTOR__}
|
|
27
27
|
{__VITEST_ERROR_CATCHER__}
|
|
28
28
|
{__VITEST_SCRIPTS__}
|
|
29
|
-
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-
|
|
29
|
+
<script type="module" crossorigin src="/__vitest_browser__/orchestrator-R-D9fwJI.js"></script>
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
|
|
31
31
|
</head>
|
|
32
32
|
<body>
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
<link rel="icon" href="{__VITEST_FAVICON__}" type="image/svg+xml">
|
|
6
6
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
7
7
|
<title>Vitest Browser Tester</title>
|
|
8
|
-
<script type="module" crossorigin src="/__vitest_browser__/tester-
|
|
8
|
+
<script type="module" crossorigin src="/__vitest_browser__/tester-B_w3in1j.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-Owv5OOOf.js">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/client.js
CHANGED
|
@@ -273,7 +273,7 @@ const PORT = location.port;
|
|
|
273
273
|
const HOST = [location.hostname, PORT].filter(Boolean).join(":");
|
|
274
274
|
const RPC_ID = PAGE_TYPE === "orchestrator" ? getBrowserState().sessionId : getBrowserState().testerId;
|
|
275
275
|
const METHOD = getBrowserState().method;
|
|
276
|
-
const ENTRY_URL = `${location.protocol === "https:" ? "wss:" : "ws:"}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&rpcId=${RPC_ID}&sessionId=${getBrowserState().sessionId}&projectName=${getBrowserState().config.name || ""}&method=${METHOD}&token=${window.VITEST_API_TOKEN}`;
|
|
276
|
+
const ENTRY_URL = `${location.protocol === "https:" ? "wss:" : "ws:"}//${HOST}/__vitest_browser_api__?type=${PAGE_TYPE}&rpcId=${RPC_ID}&sessionId=${getBrowserState().sessionId}&projectName=${getBrowserState().config.name || ""}&method=${METHOD}&token=${window.VITEST_API_TOKEN || "0"}`;
|
|
277
277
|
let setCancel = (_) => {};
|
|
278
278
|
const onCancel = new Promise((resolve) => {
|
|
279
279
|
setCancel = resolve;
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { ViteDevServer, HtmlTagDescriptor } from 'vite';
|
|
|
5
5
|
import { CancelReason, BrowserTesterOptions, TestExecutionMethod, RunnerTestFile, AfterSuiteRunMeta, UserConsoleLog, SnapshotResult, SerializedConfig, ErrorWithDiff, ParsedStack } from 'vitest';
|
|
6
6
|
import { MockedModuleSerialized } from '@vitest/mocker';
|
|
7
7
|
import { ServerIdResolution, ServerMockResolution } from '@vitest/mocker/node';
|
|
8
|
-
import { TaskResultPack, TaskEventPack } from '@vitest/runner';
|
|
8
|
+
import { TestAnnotation, TaskResultPack, TaskEventPack } from '@vitest/runner';
|
|
9
9
|
|
|
10
10
|
type ArgumentsType<T> = T extends (...args: infer A) => any ? A : never;
|
|
11
11
|
type ReturnType<T> = T extends (...args: any) => infer R ? R : never;
|
|
@@ -29,6 +29,7 @@ interface WebSocketBrowserHandlers {
|
|
|
29
29
|
onUnhandledError: (error: unknown, type: string) => Promise<void>;
|
|
30
30
|
onQueued: (method: TestExecutionMethod, file: RunnerTestFile) => void;
|
|
31
31
|
onCollected: (method: TestExecutionMethod, files: RunnerTestFile[]) => Promise<void>;
|
|
32
|
+
onTaskAnnotate: (testId: string, annotation: TestAnnotation) => Promise<TestAnnotation>;
|
|
32
33
|
onTaskUpdate: (method: TestExecutionMethod, packs: TaskResultPack[], events: TaskEventPack[]) => void;
|
|
33
34
|
onAfterSuiteRun: (meta: AfterSuiteRunMeta) => void;
|
|
34
35
|
cancelCurrentRun: (reason: CancelReason) => void;
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ import { resolve as resolve$1, basename as basename$1, dirname as dirname$1, nor
|
|
|
18
18
|
import { WebSocketServer } from 'ws';
|
|
19
19
|
import * as nodeos from 'node:os';
|
|
20
20
|
|
|
21
|
-
var version = "3.2.
|
|
21
|
+
var version = "3.2.1";
|
|
22
22
|
|
|
23
23
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
24
24
|
function normalizeWindowsPath(input = "") {
|
|
@@ -3079,6 +3079,9 @@ function setupBrowserRpc(globalServer, defaultMockerRegistry) {
|
|
|
3079
3079
|
await vitest._testRun.collected(project, files);
|
|
3080
3080
|
}
|
|
3081
3081
|
},
|
|
3082
|
+
async onTaskAnnotate(id, annotation) {
|
|
3083
|
+
return vitest._testRun.annotate(id, annotation);
|
|
3084
|
+
},
|
|
3082
3085
|
async onTaskUpdate(method, packs, events) {
|
|
3083
3086
|
if (method === "collect") {
|
|
3084
3087
|
vitest.state.updateTasks(packs);
|
|
@@ -3564,6 +3567,7 @@ async function createBrowserServer(project, configFile, prePlugins = [], postPlu
|
|
|
3564
3567
|
hmr: false,
|
|
3565
3568
|
watch: null
|
|
3566
3569
|
},
|
|
3570
|
+
cacheDir: project.vite.config.cacheDir,
|
|
3567
3571
|
plugins: [
|
|
3568
3572
|
...prePlugins,
|
|
3569
3573
|
...project.options?.plugins || [],
|
package/dist/state.js
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.2.
|
|
4
|
+
"version": "3.2.1",
|
|
5
5
|
"description": "Browser running for Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -66,7 +66,7 @@
|
|
|
66
66
|
"peerDependencies": {
|
|
67
67
|
"playwright": "*",
|
|
68
68
|
"webdriverio": "^7.0.0 || ^8.0.0 || ^9.0.0",
|
|
69
|
-
"vitest": "3.2.
|
|
69
|
+
"vitest": "3.2.1"
|
|
70
70
|
},
|
|
71
71
|
"peerDependenciesMeta": {
|
|
72
72
|
"playwright": {
|
|
@@ -86,13 +86,13 @@
|
|
|
86
86
|
"sirv": "^3.0.1",
|
|
87
87
|
"tinyrainbow": "^2.0.0",
|
|
88
88
|
"ws": "^8.18.2",
|
|
89
|
-
"@vitest/mocker": "3.2.
|
|
90
|
-
"@vitest/utils": "3.2.
|
|
89
|
+
"@vitest/mocker": "3.2.1",
|
|
90
|
+
"@vitest/utils": "3.2.1"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
93
|
"@types/ws": "^8.18.1",
|
|
94
|
-
"@wdio/protocols": "^9.
|
|
95
|
-
"@wdio/types": "^9.
|
|
94
|
+
"@wdio/protocols": "^9.15.0",
|
|
95
|
+
"@wdio/types": "^9.15.0",
|
|
96
96
|
"birpc": "2.3.0",
|
|
97
97
|
"flatted": "^3.3.3",
|
|
98
98
|
"ivya": "^1.6.0",
|
|
@@ -102,11 +102,11 @@
|
|
|
102
102
|
"playwright": "^1.52.0",
|
|
103
103
|
"playwright-core": "^1.52.0",
|
|
104
104
|
"safaridriver": "^1.0.0",
|
|
105
|
-
"webdriverio": "^9.
|
|
106
|
-
"@vitest/runner": "3.2.
|
|
107
|
-
"
|
|
108
|
-
"@vitest/ui": "3.2.
|
|
109
|
-
"vitest": "3.2.
|
|
105
|
+
"webdriverio": "^9.15.0",
|
|
106
|
+
"@vitest/runner": "3.2.1",
|
|
107
|
+
"vitest": "3.2.1",
|
|
108
|
+
"@vitest/ui": "3.2.1",
|
|
109
|
+
"@vitest/ws-client": "3.2.1"
|
|
110
110
|
},
|
|
111
111
|
"scripts": {
|
|
112
112
|
"build": "rimraf dist && pnpm build:node && pnpm build:client",
|