@vitest/browser 3.0.7 → 3.0.8
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/dist/client/.vite/manifest.json +2 -2
- package/dist/client/__vitest__/assets/{index-BX_iUIjH.js → index-BAYvVM30.js} +25 -25
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{orchestrator-DeY4LJgz.js → orchestrator-C0dFtnHa.js} +1 -1
- package/dist/client/__vitest_browser__/{tester-Cqa_buNy.js → tester-CHxkAhrF.js} +27 -13
- package/dist/client/error-catcher.js +10 -0
- package/dist/client/orchestrator.html +1 -1
- package/dist/client/tester/tester.html +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.js +40 -9
- package/package.json +8 -9
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
})();
|
|
24
24
|
</script>
|
|
25
25
|
<!-- !LOAD_METADATA! -->
|
|
26
|
-
<script type="module" src="./assets/index-
|
|
26
|
+
<script type="module" src="./assets/index-BAYvVM30.js"></script>
|
|
27
27
|
<link rel="stylesheet" href="./assets/index-CV9H8iCm.css">
|
|
28
28
|
</head>
|
|
29
29
|
<body>
|
package/dist/client/__vitest_browser__/{orchestrator-DeY4LJgz.js → orchestrator-C0dFtnHa.js}
RENAMED
|
@@ -54,7 +54,7 @@ class IframeOrchestrator {
|
|
|
54
54
|
const { width, height } = config.browser.viewport;
|
|
55
55
|
this.iframes.forEach((iframe) => iframe.remove());
|
|
56
56
|
this.iframes.clear();
|
|
57
|
-
if (config.isolate === false) {
|
|
57
|
+
if (config.browser.isolate === false) {
|
|
58
58
|
debug("create iframe", ID_ALL);
|
|
59
59
|
const iframe = this.createIframe(container, ID_ALL);
|
|
60
60
|
await setIframeViewport(iframe, width, height);
|
|
@@ -15025,7 +15025,9 @@ function extractLocation(urlLike) {
|
|
|
15025
15025
|
}
|
|
15026
15026
|
if (url2.startsWith("http:") || url2.startsWith("https:")) {
|
|
15027
15027
|
const urlObj = new URL(url2);
|
|
15028
|
-
|
|
15028
|
+
urlObj.searchParams.delete("import");
|
|
15029
|
+
urlObj.searchParams.delete("browserv");
|
|
15030
|
+
url2 = urlObj.pathname + urlObj.hash + urlObj.search;
|
|
15029
15031
|
}
|
|
15030
15032
|
if (url2.startsWith("/@fs/")) {
|
|
15031
15033
|
const isWindows = /^\/@fs\/[a-zA-Z]:\//.test(url2);
|
|
@@ -15110,28 +15112,40 @@ function createStackString(stacks) {
|
|
|
15110
15112
|
}
|
|
15111
15113
|
function parseStacktrace(stack, options = {}) {
|
|
15112
15114
|
const { ignoreStackEntries = stackIgnorePatterns } = options;
|
|
15113
|
-
|
|
15114
|
-
if (ignoreStackEntries.length) {
|
|
15115
|
-
stacks = stacks.filter(
|
|
15116
|
-
(stack2) => !ignoreStackEntries.some((p) => stack2.file.match(p))
|
|
15117
|
-
);
|
|
15118
|
-
}
|
|
15115
|
+
const stacks = !CHROME_IE_STACK_REGEXP.test(stack) ? parseFFOrSafariStackTrace(stack) : parseV8Stacktrace(stack);
|
|
15119
15116
|
return stacks.map((stack2) => {
|
|
15120
15117
|
var _a;
|
|
15121
|
-
if (options.
|
|
15122
|
-
stack2.file = options.
|
|
15118
|
+
if (options.getUrlId) {
|
|
15119
|
+
stack2.file = options.getUrlId(stack2.file);
|
|
15123
15120
|
}
|
|
15124
15121
|
const map = (_a = options.getSourceMap) == null ? void 0 : _a.call(options, stack2.file);
|
|
15125
15122
|
if (!map || typeof map !== "object" || !map.version) {
|
|
15126
|
-
return stack2;
|
|
15123
|
+
return shouldFilter(ignoreStackEntries, stack2.file) ? null : stack2;
|
|
15127
15124
|
}
|
|
15128
15125
|
const traceMap = new traceMapping_umdExports.TraceMap(map);
|
|
15129
|
-
const { line, column } = traceMapping_umdExports.originalPositionFor(traceMap, stack2);
|
|
15126
|
+
const { line, column, source: source2, name } = traceMapping_umdExports.originalPositionFor(traceMap, stack2);
|
|
15127
|
+
let file = stack2.file;
|
|
15128
|
+
if (source2) {
|
|
15129
|
+
const fileUrl = stack2.file.startsWith("file://") ? stack2.file : `file://${stack2.file}`;
|
|
15130
|
+
const sourceRootUrl = map.sourceRoot ? new URL(map.sourceRoot, fileUrl) : fileUrl;
|
|
15131
|
+
file = new URL(source2, sourceRootUrl).pathname;
|
|
15132
|
+
}
|
|
15133
|
+
if (shouldFilter(ignoreStackEntries, file)) {
|
|
15134
|
+
return null;
|
|
15135
|
+
}
|
|
15130
15136
|
if (line != null && column != null) {
|
|
15131
|
-
return {
|
|
15137
|
+
return {
|
|
15138
|
+
line,
|
|
15139
|
+
column,
|
|
15140
|
+
file,
|
|
15141
|
+
method: name || stack2.method
|
|
15142
|
+
};
|
|
15132
15143
|
}
|
|
15133
15144
|
return stack2;
|
|
15134
|
-
});
|
|
15145
|
+
}).filter((s) => s != null);
|
|
15146
|
+
}
|
|
15147
|
+
function shouldFilter(ignoreStackEntries, file) {
|
|
15148
|
+
return ignoreStackEntries.some((p) => file.match(p));
|
|
15135
15149
|
}
|
|
15136
15150
|
function parseFFOrSafariStackTrace(stack) {
|
|
15137
15151
|
return stack.split("\n").map((line) => parseSingleFFOrSafariStack(line)).filter(notNullish);
|
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import { channel, client } from '@vitest/browser/client'
|
|
2
2
|
|
|
3
3
|
function serializeError(unhandledError) {
|
|
4
|
+
const state = globalThis.__vitest_worker__
|
|
5
|
+
const VITEST_TEST_NAME = state && state.current && state.current.type === 'test'
|
|
6
|
+
? state.current.name
|
|
7
|
+
: undefined
|
|
8
|
+
const VITEST_TEST_PATH = state && state.filepath ? state.filepath : undefined
|
|
9
|
+
|
|
4
10
|
if (typeof unhandledError !== 'object' || !unhandledError) {
|
|
5
11
|
return {
|
|
6
12
|
message: String(unhandledError),
|
|
13
|
+
VITEST_TEST_NAME,
|
|
14
|
+
VITEST_TEST_PATH,
|
|
7
15
|
}
|
|
8
16
|
}
|
|
9
17
|
|
|
@@ -11,6 +19,8 @@ function serializeError(unhandledError) {
|
|
|
11
19
|
name: unhandledError.name,
|
|
12
20
|
message: unhandledError.message,
|
|
13
21
|
stack: String(unhandledError.stack),
|
|
22
|
+
VITEST_TEST_NAME,
|
|
23
|
+
VITEST_TEST_PATH,
|
|
14
24
|
}
|
|
15
25
|
}
|
|
16
26
|
|
|
@@ -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-C0dFtnHa.js"></script>
|
|
30
30
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-CBFLDkwI.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-CHxkAhrF.js"></script>
|
|
9
9
|
<link rel="modulepreload" crossorigin href="/__vitest_browser__/utils-CBFLDkwI.js">
|
|
10
10
|
</head>
|
|
11
11
|
<body>
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,7 @@ declare class ParentBrowserProject {
|
|
|
126
126
|
children: Set<ProjectBrowser>;
|
|
127
127
|
vitest: Vitest;
|
|
128
128
|
config: ResolvedConfig;
|
|
129
|
+
private sourceMapCache;
|
|
129
130
|
constructor(project: TestProject, base: string);
|
|
130
131
|
setServer(vite: Vite.ViteDevServer): void;
|
|
131
132
|
spawn(project: TestProject): ProjectBrowser;
|
|
@@ -140,6 +141,7 @@ declare class ParentBrowserProject {
|
|
|
140
141
|
sessionId: string;
|
|
141
142
|
testFile: string;
|
|
142
143
|
};
|
|
144
|
+
private retrieveSourceMapURL;
|
|
143
145
|
}
|
|
144
146
|
|
|
145
147
|
declare const distRoot: string;
|
package/dist/index.js
CHANGED
|
@@ -16,7 +16,7 @@ import { resolve as resolve$1, dirname as dirname$1, basename as basename$1, nor
|
|
|
16
16
|
import { WebSocketServer } from 'ws';
|
|
17
17
|
import * as nodeos from 'node:os';
|
|
18
18
|
|
|
19
|
-
var version = "3.0.
|
|
19
|
+
var version = "3.0.8";
|
|
20
20
|
|
|
21
21
|
const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
|
|
22
22
|
function normalizeWindowsPath(input = "") {
|
|
@@ -776,8 +776,7 @@ var BrowserPlugin = (parentServer, base = "/") => {
|
|
|
776
776
|
"vitest > chai",
|
|
777
777
|
"vitest > chai > loupe",
|
|
778
778
|
"vitest > @vitest/utils > loupe",
|
|
779
|
-
"@vitest/browser > @testing-library/user-event"
|
|
780
|
-
"@vitest/browser > @testing-library/dom"
|
|
779
|
+
"@vitest/browser > @testing-library/user-event"
|
|
781
780
|
];
|
|
782
781
|
const fileRoot = browserTestFiles[0] ? dirname(browserTestFiles[0]) : project.config.root;
|
|
783
782
|
const svelte = isPackageExists("vitest-browser-svelte", fileRoot);
|
|
@@ -2476,17 +2475,36 @@ class ParentBrowserProject {
|
|
|
2476
2475
|
this.stackTraceOptions = {
|
|
2477
2476
|
frameFilter: project.config.onStackTrace,
|
|
2478
2477
|
getSourceMap: (id) => {
|
|
2478
|
+
if (this.sourceMapCache.has(id)) {
|
|
2479
|
+
return this.sourceMapCache.get(id);
|
|
2480
|
+
}
|
|
2479
2481
|
const result = this.vite.moduleGraph.getModuleById(id)?.transformResult;
|
|
2482
|
+
if (result && !result.map) {
|
|
2483
|
+
const sourceMapUrl = this.retrieveSourceMapURL(result.code);
|
|
2484
|
+
if (!sourceMapUrl) {
|
|
2485
|
+
return null;
|
|
2486
|
+
}
|
|
2487
|
+
const filepathDir = dirname(id);
|
|
2488
|
+
const sourceMapPath = resolve(filepathDir, sourceMapUrl);
|
|
2489
|
+
const map = JSON.parse(readFileSync(sourceMapPath, "utf-8"));
|
|
2490
|
+
this.sourceMapCache.set(id, map);
|
|
2491
|
+
return map;
|
|
2492
|
+
}
|
|
2480
2493
|
return result?.map;
|
|
2481
2494
|
},
|
|
2482
|
-
|
|
2495
|
+
getUrlId: (id) => {
|
|
2483
2496
|
const mod = this.vite.moduleGraph.getModuleById(id);
|
|
2484
|
-
if (mod
|
|
2485
|
-
return
|
|
2497
|
+
if (mod) {
|
|
2498
|
+
return id;
|
|
2486
2499
|
}
|
|
2487
|
-
const
|
|
2488
|
-
|
|
2489
|
-
|
|
2500
|
+
const resolvedPath = resolve(project.config.root, id.slice(1));
|
|
2501
|
+
const modUrl = this.vite.moduleGraph.getModuleById(resolvedPath);
|
|
2502
|
+
if (modUrl) {
|
|
2503
|
+
return resolvedPath;
|
|
2504
|
+
}
|
|
2505
|
+
const files = this.vite.moduleGraph.getModulesByFile(resolvedPath);
|
|
2506
|
+
if (files && files.size) {
|
|
2507
|
+
return files.values().next().value.id;
|
|
2490
2508
|
}
|
|
2491
2509
|
return id;
|
|
2492
2510
|
}
|
|
@@ -2541,6 +2559,8 @@ class ParentBrowserProject {
|
|
|
2541
2559
|
children = /* @__PURE__ */ new Set();
|
|
2542
2560
|
vitest;
|
|
2543
2561
|
config;
|
|
2562
|
+
// cache for non-vite source maps
|
|
2563
|
+
sourceMapCache = /* @__PURE__ */ new Map();
|
|
2544
2564
|
setServer(vite) {
|
|
2545
2565
|
this.vite = vite;
|
|
2546
2566
|
}
|
|
@@ -2641,6 +2661,17 @@ class ParentBrowserProject {
|
|
|
2641
2661
|
const decodedTestFile = decodeURIComponent(testFile);
|
|
2642
2662
|
return { sessionId, testFile: decodedTestFile };
|
|
2643
2663
|
}
|
|
2664
|
+
retrieveSourceMapURL(source) {
|
|
2665
|
+
const re = /\/\/[@#]\s*sourceMappingURL=([^\s'"]+)\s*$|\/\*[@#]\s*sourceMappingURL=[^\s*'"]+\s*\*\/\s*$/gm;
|
|
2666
|
+
let lastMatch, match;
|
|
2667
|
+
while (match = re.exec(source)) {
|
|
2668
|
+
lastMatch = match;
|
|
2669
|
+
}
|
|
2670
|
+
if (!lastMatch) {
|
|
2671
|
+
return null;
|
|
2672
|
+
}
|
|
2673
|
+
return lastMatch[1];
|
|
2674
|
+
}
|
|
2644
2675
|
}
|
|
2645
2676
|
|
|
2646
2677
|
const DEFAULT_TIMEOUT = 6e4;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "3.0.
|
|
4
|
+
"version": "3.0.8",
|
|
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.0.
|
|
69
|
+
"vitest": "3.0.8"
|
|
70
70
|
},
|
|
71
71
|
"peerDependenciesMeta": {
|
|
72
72
|
"playwright": {
|
|
@@ -80,15 +80,14 @@
|
|
|
80
80
|
}
|
|
81
81
|
},
|
|
82
82
|
"dependencies": {
|
|
83
|
-
"@testing-library/dom": "^10.4.0",
|
|
84
83
|
"@testing-library/user-event": "^14.6.1",
|
|
85
84
|
"magic-string": "^0.30.17",
|
|
86
85
|
"msw": "^2.7.3",
|
|
87
86
|
"sirv": "^3.0.1",
|
|
88
87
|
"tinyrainbow": "^2.0.0",
|
|
89
88
|
"ws": "^8.18.1",
|
|
90
|
-
"@vitest/
|
|
91
|
-
"@vitest/
|
|
89
|
+
"@vitest/utils": "3.0.8",
|
|
90
|
+
"@vitest/mocker": "3.0.8"
|
|
92
91
|
},
|
|
93
92
|
"devDependencies": {
|
|
94
93
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -105,10 +104,10 @@
|
|
|
105
104
|
"playwright-core": "^1.50.1",
|
|
106
105
|
"safaridriver": "^1.0.0",
|
|
107
106
|
"webdriverio": "^9.10.0",
|
|
108
|
-
"@vitest/runner": "3.0.
|
|
109
|
-
"@vitest/ui": "3.0.
|
|
110
|
-
"@vitest/ws-client": "3.0.
|
|
111
|
-
"vitest": "3.0.
|
|
107
|
+
"@vitest/runner": "3.0.8",
|
|
108
|
+
"@vitest/ui": "3.0.8",
|
|
109
|
+
"@vitest/ws-client": "3.0.8",
|
|
110
|
+
"vitest": "3.0.8"
|
|
112
111
|
},
|
|
113
112
|
"scripts": {
|
|
114
113
|
"build": "rimraf dist && pnpm build:node && pnpm build:client",
|