@vitest/browser 1.1.0 → 1.1.2
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/__vitest__/assets/index-IJeHjHTb.js +33 -0
- package/dist/client/__vitest__/index.html +1 -1
- package/dist/client/__vitest_browser__/{index-JmUxqpfn.js → index-CO7GSZ7y.js} +15 -10
- package/dist/client/index.html +1 -1
- package/dist/index.js +6 -170
- package/dist/providers.js +0 -9
- package/package.json +10 -12
- package/dist/client/__vitest__/assets/index-O8DR2YZv.js +0 -33
|
@@ -17,7 +17,7 @@
|
|
|
17
17
|
})()
|
|
18
18
|
</script>
|
|
19
19
|
<!-- !LOAD_METADATA! -->
|
|
20
|
-
<script type="module" crossorigin src="./assets/index-
|
|
20
|
+
<script type="module" crossorigin src="./assets/index-IJeHjHTb.js"></script>
|
|
21
21
|
<link rel="stylesheet" crossorigin href="./assets/index-z19Uws5U.css">
|
|
22
22
|
</head>
|
|
23
23
|
<body>
|
|
@@ -647,8 +647,8 @@ function createSafeRpc(client2, getTimers) {
|
|
|
647
647
|
function rpc() {
|
|
648
648
|
return globalThis.__vitest_worker__.safeRpc;
|
|
649
649
|
}
|
|
650
|
-
function createBrowserRunner(
|
|
651
|
-
return class BrowserTestRunner extends
|
|
650
|
+
function createBrowserRunner(VitestRunner, coverageModule) {
|
|
651
|
+
return class BrowserTestRunner extends VitestRunner {
|
|
652
652
|
constructor(options) {
|
|
653
653
|
super(options.config);
|
|
654
654
|
__publicField(this, "config");
|
|
@@ -695,18 +695,21 @@ function createBrowserRunner(original, coverageModule) {
|
|
|
695
695
|
hash = Date.now().toString();
|
|
696
696
|
this.hashMap.set(filepath, [false, hash]);
|
|
697
697
|
}
|
|
698
|
-
const
|
|
698
|
+
const base = this.config.base || "/";
|
|
699
|
+
const prefix = `${base}${/^\w:/.test(filepath) ? "@fs/" : ""}`;
|
|
700
|
+
const query = `${test ? "browserv" : "v"}=${hash}`;
|
|
701
|
+
const importpath = `${prefix}${filepath}?${query}`.replace(/\/+/g, "/");
|
|
699
702
|
await __vitePreload(() => import(importpath), true ? __vite__mapDeps([]) : void 0);
|
|
700
703
|
}
|
|
701
704
|
};
|
|
702
705
|
}
|
|
703
|
-
async function importId(id) {
|
|
704
|
-
const name =
|
|
706
|
+
async function importId$1(id, basePath2) {
|
|
707
|
+
const name = `${basePath2}@id/${id}`;
|
|
705
708
|
return __vi_wrap_module__(__vitePreload(() => import(name), true ? __vite__mapDeps([]) : void 0));
|
|
706
709
|
}
|
|
707
710
|
const { Date: Date$1, console: console$1 } = globalThis;
|
|
708
|
-
async function setupConsoleLogSpy() {
|
|
709
|
-
const { stringify: stringify2, format, inspect } = await importId("vitest/utils");
|
|
711
|
+
async function setupConsoleLogSpy(basePath2) {
|
|
712
|
+
const { stringify: stringify2, format, inspect } = await importId$1("vitest/utils", basePath2);
|
|
710
713
|
const { log, info, error, dir, dirxml, trace, time, timeEnd, timeLog, warn, debug, count, countReset } = console$1;
|
|
711
714
|
const formatInput = (input) => {
|
|
712
715
|
if (input instanceof Node)
|
|
@@ -865,6 +868,9 @@ const browserHashMap = /* @__PURE__ */ new Map();
|
|
|
865
868
|
const url = new URL(location.href);
|
|
866
869
|
const testId = url.searchParams.get("id") || "unknown";
|
|
867
870
|
const reloadTries = Number(url.searchParams.get("reloadTries") || "0");
|
|
871
|
+
const basePath = () => (config == null ? void 0 : config.base) || "/";
|
|
872
|
+
const importId = (id) => importId$1(id, basePath());
|
|
873
|
+
const viteClientPath = () => `${basePath()}@vite/client`;
|
|
868
874
|
function getQueryPaths() {
|
|
869
875
|
return url.searchParams.getAll("path");
|
|
870
876
|
}
|
|
@@ -992,13 +998,12 @@ ws.addEventListener("open", async () => {
|
|
|
992
998
|
const paths = getQueryPaths();
|
|
993
999
|
const iFrame = document.getElementById("vitest-ui");
|
|
994
1000
|
iFrame.setAttribute("src", "/__vitest__/");
|
|
995
|
-
await setupConsoleLogSpy();
|
|
1001
|
+
await setupConsoleLogSpy(basePath());
|
|
996
1002
|
setupDialogsSpy();
|
|
997
1003
|
await runTests(paths, config);
|
|
998
1004
|
});
|
|
999
1005
|
async function prepareTestEnvironment(config2) {
|
|
1000
|
-
|
|
1001
|
-
await __vitePreload(() => import(viteClientPath), true ? __vite__mapDeps([]) : void 0);
|
|
1006
|
+
await __vitePreload(() => import(viteClientPath()), true ? __vite__mapDeps([]) : void 0);
|
|
1002
1007
|
const {
|
|
1003
1008
|
startTests,
|
|
1004
1009
|
setupCommonEnv,
|
package/dist/client/index.html
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
border: none;
|
|
22
22
|
}
|
|
23
23
|
</style>
|
|
24
|
-
<script type="module" crossorigin src="/__vitest_browser__/index-
|
|
24
|
+
<script type="module" crossorigin src="/__vitest_browser__/index-CO7GSZ7y.js"></script>
|
|
25
25
|
</head>
|
|
26
26
|
<body>
|
|
27
27
|
<iframe id="vitest-ui" src=""></iframe>
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ import { resolve } from 'node:path';
|
|
|
3
3
|
import { builtinModules } from 'node:module';
|
|
4
4
|
import sirv from 'sirv';
|
|
5
5
|
import MagicString from 'magic-string';
|
|
6
|
-
import {
|
|
6
|
+
import { esmWalker } from '@vitest/utils/ast';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* @param {import('estree').Node} param
|
|
@@ -62,168 +62,6 @@ function extract_identifiers(param, nodes = []) {
|
|
|
62
62
|
return nodes;
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
const isNodeInPatternWeakSet = /* @__PURE__ */ new WeakSet();
|
|
66
|
-
function setIsNodeInPattern(node) {
|
|
67
|
-
return isNodeInPatternWeakSet.add(node);
|
|
68
|
-
}
|
|
69
|
-
function isNodeInPattern(node) {
|
|
70
|
-
return isNodeInPatternWeakSet.has(node);
|
|
71
|
-
}
|
|
72
|
-
function esmWalker(root, { onIdentifier, onImportMeta, onDynamicImport }) {
|
|
73
|
-
const parentStack = [];
|
|
74
|
-
const varKindStack = [];
|
|
75
|
-
const scopeMap = /* @__PURE__ */ new WeakMap();
|
|
76
|
-
const identifiers = [];
|
|
77
|
-
const setScope = (node, name) => {
|
|
78
|
-
let scopeIds = scopeMap.get(node);
|
|
79
|
-
if (scopeIds && scopeIds.has(name))
|
|
80
|
-
return;
|
|
81
|
-
if (!scopeIds) {
|
|
82
|
-
scopeIds = /* @__PURE__ */ new Set();
|
|
83
|
-
scopeMap.set(node, scopeIds);
|
|
84
|
-
}
|
|
85
|
-
scopeIds.add(name);
|
|
86
|
-
};
|
|
87
|
-
function isInScope(name, parents) {
|
|
88
|
-
return parents.some((node) => node && scopeMap.get(node)?.has(name));
|
|
89
|
-
}
|
|
90
|
-
function handlePattern(p, parentScope) {
|
|
91
|
-
if (p.type === "Identifier") {
|
|
92
|
-
setScope(parentScope, p.name);
|
|
93
|
-
} else if (p.type === "RestElement") {
|
|
94
|
-
handlePattern(p.argument, parentScope);
|
|
95
|
-
} else if (p.type === "ObjectPattern") {
|
|
96
|
-
p.properties.forEach((property) => {
|
|
97
|
-
if (property.type === "RestElement")
|
|
98
|
-
setScope(parentScope, property.argument.name);
|
|
99
|
-
else
|
|
100
|
-
handlePattern(property.value, parentScope);
|
|
101
|
-
});
|
|
102
|
-
} else if (p.type === "ArrayPattern") {
|
|
103
|
-
p.elements.forEach((element) => {
|
|
104
|
-
if (element)
|
|
105
|
-
handlePattern(element, parentScope);
|
|
106
|
-
});
|
|
107
|
-
} else if (p.type === "AssignmentPattern") {
|
|
108
|
-
handlePattern(p.left, parentScope);
|
|
109
|
-
} else {
|
|
110
|
-
setScope(parentScope, p.name);
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
walk(root, {
|
|
114
|
-
enter(node, parent) {
|
|
115
|
-
if (node.type === "ImportDeclaration")
|
|
116
|
-
return this.skip();
|
|
117
|
-
if (parent && !(parent.type === "IfStatement" && node === parent.alternate))
|
|
118
|
-
parentStack.unshift(parent);
|
|
119
|
-
if (node.type === "VariableDeclaration")
|
|
120
|
-
varKindStack.unshift(node.kind);
|
|
121
|
-
if (node.type === "MetaProperty" && node.meta.name === "import")
|
|
122
|
-
onImportMeta(node);
|
|
123
|
-
else if (node.type === "ImportExpression")
|
|
124
|
-
onDynamicImport(node);
|
|
125
|
-
if (node.type === "Identifier") {
|
|
126
|
-
if (!isInScope(node.name, parentStack) && isRefIdentifier(node, parent, parentStack)) {
|
|
127
|
-
identifiers.push([node, parentStack.slice(0)]);
|
|
128
|
-
}
|
|
129
|
-
} else if (isFunctionNode(node)) {
|
|
130
|
-
if (node.type === "FunctionDeclaration") {
|
|
131
|
-
const parentScope = findParentScope(parentStack);
|
|
132
|
-
if (parentScope)
|
|
133
|
-
setScope(parentScope, node.id.name);
|
|
134
|
-
}
|
|
135
|
-
node.params.forEach((p) => {
|
|
136
|
-
if (p.type === "ObjectPattern" || p.type === "ArrayPattern") {
|
|
137
|
-
handlePattern(p, node);
|
|
138
|
-
return;
|
|
139
|
-
}
|
|
140
|
-
walk(p.type === "AssignmentPattern" ? p.left : p, {
|
|
141
|
-
enter(child, parent2) {
|
|
142
|
-
if (parent2?.type === "AssignmentPattern" && parent2?.right === child)
|
|
143
|
-
return this.skip();
|
|
144
|
-
if (child.type !== "Identifier")
|
|
145
|
-
return;
|
|
146
|
-
if (isStaticPropertyKey(child, parent2))
|
|
147
|
-
return;
|
|
148
|
-
if (parent2?.type === "TemplateLiteral" && parent2?.expressions.includes(child) || parent2?.type === "CallExpression" && parent2?.callee === child)
|
|
149
|
-
return;
|
|
150
|
-
setScope(node, child.name);
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
});
|
|
154
|
-
} else if (node.type === "Property" && parent.type === "ObjectPattern") {
|
|
155
|
-
setIsNodeInPattern(node);
|
|
156
|
-
} else if (node.type === "VariableDeclarator") {
|
|
157
|
-
const parentFunction = findParentScope(
|
|
158
|
-
parentStack,
|
|
159
|
-
varKindStack[0] === "var"
|
|
160
|
-
);
|
|
161
|
-
if (parentFunction)
|
|
162
|
-
handlePattern(node.id, parentFunction);
|
|
163
|
-
} else if (node.type === "CatchClause" && node.param) {
|
|
164
|
-
handlePattern(node.param, node);
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
leave(node, parent) {
|
|
168
|
-
if (parent && !(parent.type === "IfStatement" && node === parent.alternate))
|
|
169
|
-
parentStack.shift();
|
|
170
|
-
if (node.type === "VariableDeclaration")
|
|
171
|
-
varKindStack.shift();
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
identifiers.forEach(([node, stack]) => {
|
|
175
|
-
if (!isInScope(node.name, stack))
|
|
176
|
-
onIdentifier(node, stack[0], stack);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
function isRefIdentifier(id, parent, parentStack) {
|
|
180
|
-
if (parent.type === "CatchClause" || (parent.type === "VariableDeclarator" || parent.type === "ClassDeclaration") && parent.id === id)
|
|
181
|
-
return false;
|
|
182
|
-
if (isFunctionNode(parent)) {
|
|
183
|
-
if (parent.id === id)
|
|
184
|
-
return false;
|
|
185
|
-
if (parent.params.includes(id))
|
|
186
|
-
return false;
|
|
187
|
-
}
|
|
188
|
-
if (parent.type === "MethodDefinition" && !parent.computed)
|
|
189
|
-
return false;
|
|
190
|
-
if (isStaticPropertyKey(id, parent))
|
|
191
|
-
return false;
|
|
192
|
-
if (isNodeInPattern(parent) && parent.value === id)
|
|
193
|
-
return false;
|
|
194
|
-
if (parent.type === "ArrayPattern" && !isInDestructuringAssignment(parent, parentStack))
|
|
195
|
-
return false;
|
|
196
|
-
if (parent.type === "MemberExpression" && parent.property === id && !parent.computed)
|
|
197
|
-
return false;
|
|
198
|
-
if (parent.type === "ExportSpecifier")
|
|
199
|
-
return false;
|
|
200
|
-
if (id.name === "arguments")
|
|
201
|
-
return false;
|
|
202
|
-
return true;
|
|
203
|
-
}
|
|
204
|
-
function isStaticProperty(node) {
|
|
205
|
-
return node && node.type === "Property" && !node.computed;
|
|
206
|
-
}
|
|
207
|
-
function isStaticPropertyKey(node, parent) {
|
|
208
|
-
return isStaticProperty(parent) && parent.key === node;
|
|
209
|
-
}
|
|
210
|
-
const functionNodeTypeRE = /Function(?:Expression|Declaration)$|Method$/;
|
|
211
|
-
function isFunctionNode(node) {
|
|
212
|
-
return functionNodeTypeRE.test(node.type);
|
|
213
|
-
}
|
|
214
|
-
const blockNodeTypeRE = /^BlockStatement$|^For(?:In|Of)?Statement$/;
|
|
215
|
-
function isBlock(node) {
|
|
216
|
-
return blockNodeTypeRE.test(node.type);
|
|
217
|
-
}
|
|
218
|
-
function findParentScope(parentStack, isVar = false) {
|
|
219
|
-
return parentStack.find(isVar ? isFunctionNode : isBlock);
|
|
220
|
-
}
|
|
221
|
-
function isInDestructuringAssignment(parent, parentStack) {
|
|
222
|
-
if (parent && (parent.type === "Property" || parent.type === "ArrayPattern"))
|
|
223
|
-
return parentStack.some((i) => i.type === "AssignmentExpression");
|
|
224
|
-
return false;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
65
|
const viInjectedKey = "__vi_inject__";
|
|
228
66
|
const viExportAllHelper = "__vi_export_all__";
|
|
229
67
|
const skipHijack = [
|
|
@@ -375,15 +213,13 @@ export default { ${viInjectedKey}: ${viInjectedKey}.default };
|
|
|
375
213
|
}
|
|
376
214
|
}
|
|
377
215
|
esmWalker(ast, {
|
|
378
|
-
onIdentifier(id2,
|
|
379
|
-
const grandparent = parentStack[1];
|
|
216
|
+
onIdentifier(id2, info, parentStack) {
|
|
380
217
|
const binding = idToImportMap.get(id2.name);
|
|
381
218
|
if (!binding)
|
|
382
219
|
return;
|
|
383
|
-
if (
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
} else if (parent.type === "PropertyDefinition" && grandparent?.type === "ClassBody" || parent.type === "ClassDeclaration" && id2 === parent.superClass) {
|
|
220
|
+
if (info.hasBindingShortcut) {
|
|
221
|
+
s.appendLeft(id2.end, `: ${binding}`);
|
|
222
|
+
} else if (info.classDeclaration) {
|
|
387
223
|
if (!declaredConst.has(id2.name)) {
|
|
388
224
|
declaredConst.add(id2.name);
|
|
389
225
|
const topNode = parentStack[parentStack.length - 2];
|
|
@@ -392,7 +228,7 @@ export default { ${viInjectedKey}: ${viInjectedKey}.default };
|
|
|
392
228
|
}
|
|
393
229
|
} else if (
|
|
394
230
|
// don't transform class name identifier
|
|
395
|
-
!
|
|
231
|
+
!info.classExpression
|
|
396
232
|
) {
|
|
397
233
|
s.update(id2.start, id2.end, binding);
|
|
398
234
|
}
|
package/dist/providers.js
CHANGED
|
@@ -54,8 +54,6 @@ const webdriverBrowsers = ["firefox", "chrome", "edge", "safari"];
|
|
|
54
54
|
class WebdriverBrowserProvider {
|
|
55
55
|
name = "webdriverio";
|
|
56
56
|
cachedBrowser = null;
|
|
57
|
-
stopSafari = () => {
|
|
58
|
-
};
|
|
59
57
|
browser;
|
|
60
58
|
ctx;
|
|
61
59
|
options;
|
|
@@ -74,12 +72,6 @@ class WebdriverBrowserProvider {
|
|
|
74
72
|
if (this.browser === "safari") {
|
|
75
73
|
if (options.headless)
|
|
76
74
|
throw new Error("You've enabled headless mode for Safari but it doesn't currently support it.");
|
|
77
|
-
const safaridriver = await import('safaridriver');
|
|
78
|
-
safaridriver.start({ diagnose: true });
|
|
79
|
-
this.stopSafari = () => safaridriver.stop();
|
|
80
|
-
process.on("beforeExit", () => {
|
|
81
|
-
safaridriver.stop();
|
|
82
|
-
});
|
|
83
75
|
}
|
|
84
76
|
const { remote } = await import('webdriverio');
|
|
85
77
|
this.cachedBrowser = await remote({
|
|
@@ -120,7 +112,6 @@ class WebdriverBrowserProvider {
|
|
|
120
112
|
}
|
|
121
113
|
async close() {
|
|
122
114
|
await Promise.all([
|
|
123
|
-
this.stopSafari(),
|
|
124
115
|
this.cachedBrowser?.sessionId ? this.cachedBrowser?.deleteSession?.() : null
|
|
125
116
|
]);
|
|
126
117
|
process.exit();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/browser",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "1.1.
|
|
4
|
+
"version": "1.1.2",
|
|
5
5
|
"description": "Browser running for Vitest",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"funding": "https://opencollective.com/vitest",
|
|
@@ -42,7 +42,6 @@
|
|
|
42
42
|
],
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"playwright": "*",
|
|
45
|
-
"safaridriver": "*",
|
|
46
45
|
"vitest": "^1.0.0",
|
|
47
46
|
"webdriverio": "*"
|
|
48
47
|
},
|
|
@@ -58,23 +57,22 @@
|
|
|
58
57
|
}
|
|
59
58
|
},
|
|
60
59
|
"dependencies": {
|
|
61
|
-
"estree-walker": "^3.0.3",
|
|
62
60
|
"magic-string": "^0.30.5",
|
|
63
|
-
"sirv": "^2.0.
|
|
61
|
+
"sirv": "^2.0.4",
|
|
62
|
+
"@vitest/utils": "1.1.2"
|
|
64
63
|
},
|
|
65
64
|
"devDependencies": {
|
|
66
|
-
"@types/estree": "^1.0.5",
|
|
67
65
|
"@types/ws": "^8.5.9",
|
|
68
66
|
"@wdio/protocols": "^8.22.0",
|
|
69
67
|
"periscopic": "^4.0.2",
|
|
70
|
-
"playwright": "^1.40.
|
|
71
|
-
"playwright-core": "^1.40.
|
|
72
|
-
"safaridriver": "^0.1.
|
|
68
|
+
"playwright": "^1.40.1",
|
|
69
|
+
"playwright-core": "^1.40.1",
|
|
70
|
+
"safaridriver": "^0.1.1",
|
|
73
71
|
"webdriverio": "^8.22.1",
|
|
74
|
-
"@vitest/
|
|
75
|
-
"
|
|
76
|
-
"@vitest/ws-client": "1.1.
|
|
77
|
-
"vitest": "1.1.
|
|
72
|
+
"@vitest/ui": "1.1.2",
|
|
73
|
+
"vitest": "1.1.2",
|
|
74
|
+
"@vitest/ws-client": "1.1.2",
|
|
75
|
+
"@vitest/runner": "1.1.2"
|
|
78
76
|
},
|
|
79
77
|
"scripts": {
|
|
80
78
|
"build": "rimraf dist && pnpm build:node && pnpm build:client",
|