@vitest/coverage-v8 5.1.0-beta.1 → 5.1.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/dist/provider.js +20 -9
- package/package.json +8 -8
package/dist/provider.js
CHANGED
|
@@ -13,7 +13,7 @@ import { c as commands, n as normalize } from './commands-C6w5FFZp.js';
|
|
|
13
13
|
import 'node:crypto';
|
|
14
14
|
import 'node:fs/promises';
|
|
15
15
|
|
|
16
|
-
var version = "5.1.
|
|
16
|
+
var version = "5.1.1";
|
|
17
17
|
|
|
18
18
|
const FILE_PROTOCOL = "file://";
|
|
19
19
|
const debug = createDebug("vitest:coverage");
|
|
@@ -51,15 +51,16 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
|
51
51
|
await this.readCoverageFiles({
|
|
52
52
|
onFileRead(coverage) {
|
|
53
53
|
for (const script of coverage.result) {
|
|
54
|
-
const
|
|
54
|
+
const isExtendedContext = autoAttachSubprocess && script.isExtendedContext;
|
|
55
|
+
// Same file can run in both module runner and child process, but with different source code
|
|
56
|
+
const key = isExtendedContext ? `extended-context:${script.url}` : script.url;
|
|
57
|
+
const previous = mergedScripts.get(key);
|
|
55
58
|
const merged = mergeScriptCovs(previous ? [previous, script] : [script]);
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
merged.startOffset ||= startOffset;
|
|
59
|
-
if (autoAttachSubprocess && isExtendedContext) {
|
|
59
|
+
merged.startOffset ||= previous?.startOffset || script.startOffset || 0;
|
|
60
|
+
if (isExtendedContext) {
|
|
60
61
|
merged.isExtendedContext = true;
|
|
61
62
|
}
|
|
62
|
-
mergedScripts.set(
|
|
63
|
+
mergedScripts.set(key, merged);
|
|
63
64
|
}
|
|
64
65
|
},
|
|
65
66
|
onFinished: async (project, environment) => {
|
|
@@ -187,8 +188,17 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
|
187
188
|
}
|
|
188
189
|
// CJS imports as ternaries - e.g.
|
|
189
190
|
// const React = __vite__cjsImport0_react.__esModule ? __vite__cjsImport0_react.default : __vite__cjsImport0_react;
|
|
190
|
-
|
|
191
|
-
|
|
191
|
+
// const React = !__vite__cjsImport0_react.__esModule ? __vite__cjsImport0_react : __vite__cjsImport0_react.default;
|
|
192
|
+
if (type === "branch" && node.type === "ConditionalExpression") {
|
|
193
|
+
const test = node.test.type === "UnaryExpression" && node.test.operator === "!" ? node.test.argument : node.test;
|
|
194
|
+
if (test.type === "MemberExpression" && test.object.type === "Identifier" && test.object.name.startsWith("__vite__cjsImport") && test.property.type === "Identifier" && test.property.name === "__esModule") {
|
|
195
|
+
return true;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
// CJS namespace imports wrapped in interop helper - e.g.
|
|
199
|
+
// const React = ((m, n) => n || !m?.__esModule ? { ...m, default: m } : m)(__vite__cjsImport0_react, 1);
|
|
200
|
+
if (type === "statement" && node.type === "VariableDeclarator" && node.init?.type === "CallExpression" && node.init.callee.type === "ArrowFunctionExpression" && node.init.arguments[0]?.type === "Identifier" && node.init.arguments[0].name.startsWith("__vite__cjsImport")) {
|
|
201
|
+
return "ignore-this-and-nested-nodes";
|
|
192
202
|
}
|
|
193
203
|
// in-source test with "if (import.meta.vitest)"
|
|
194
204
|
if ((type === "branch" || type === "statement") && node.type === "IfStatement" && node.test.type === "MemberExpression" && node.test.property.type === "Identifier" && node.test.property.name === "vitest") {
|
|
@@ -213,6 +223,7 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
|
213
223
|
if (type === "statement" && node.type === "ExpressionStatement" && node.expression.type === "CallExpression" && node.expression.callee.type === "Identifier" && node.expression.callee.name === "_ts_decorate") {
|
|
214
224
|
return "ignore-this-and-nested-nodes";
|
|
215
225
|
}
|
|
226
|
+
return this.options.ignoreNode?.(node, type);
|
|
216
227
|
}
|
|
217
228
|
});
|
|
218
229
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/coverage-v8",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "5.1.
|
|
4
|
+
"version": "5.1.1",
|
|
5
5
|
"description": "V8 coverage provider for Vitest",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -41,8 +41,8 @@
|
|
|
41
41
|
"dist"
|
|
42
42
|
],
|
|
43
43
|
"peerDependencies": {
|
|
44
|
-
"@vitest/browser": "5.1.
|
|
45
|
-
"vitest": "5.1.
|
|
44
|
+
"@vitest/browser": "5.1.1",
|
|
45
|
+
"vitest": "5.1.1"
|
|
46
46
|
},
|
|
47
47
|
"peerDependenciesMeta": {
|
|
48
48
|
"@vitest/browser": {
|
|
@@ -51,8 +51,8 @@
|
|
|
51
51
|
},
|
|
52
52
|
"dependencies": {
|
|
53
53
|
"@bcoe/v8-coverage": "^1.0.2",
|
|
54
|
-
"@vitest/istanbul-lib-coverage": "^1.0
|
|
55
|
-
"@vitest/istanbul-lib-report": "^1.0
|
|
54
|
+
"@vitest/istanbul-lib-coverage": "^2.1.0",
|
|
55
|
+
"@vitest/istanbul-lib-report": "^2.1.0",
|
|
56
56
|
"ast-v8-to-istanbul": "^1.0.7",
|
|
57
57
|
"magicast": "^0.5.5",
|
|
58
58
|
"obug": "^3.0.0",
|
|
@@ -60,10 +60,10 @@
|
|
|
60
60
|
"tinyrainbow": "^3.2.0"
|
|
61
61
|
},
|
|
62
62
|
"devDependencies": {
|
|
63
|
-
"@vitest/browser": "5.1.
|
|
64
|
-
"@vitest/browser-playwright": "5.1.
|
|
63
|
+
"@vitest/browser": "5.1.1",
|
|
64
|
+
"@vitest/browser-playwright": "5.1.1",
|
|
65
65
|
"pathe": "^2.0.3",
|
|
66
|
-
"vitest": "5.1.
|
|
66
|
+
"vitest": "5.1.1"
|
|
67
67
|
},
|
|
68
68
|
"scripts": {
|
|
69
69
|
"build": "premove dist && rollup -c",
|