@vitest/coverage-v8 2.1.0-beta.3 → 2.1.0-beta.5
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 +32 -13
- package/package.json +4 -4
package/dist/provider.js
CHANGED
@@ -2248,6 +2248,8 @@ function cleanUrl(url) {
|
|
2248
2248
|
"wasi"
|
2249
2249
|
]);
|
2250
2250
|
|
2251
|
+
var version = "2.1.0-beta.5";
|
2252
|
+
|
2251
2253
|
const WRAPPER_LENGTH = 185;
|
2252
2254
|
const VITE_EXPORTS_LINE_PATTERN = /Object\.defineProperty\(__vite_ssr_exports__.*\n/g;
|
2253
2255
|
const DECORATOR_METADATA_PATTERN = /_ts_metadata\("design:paramtypes", \[[^\]]*\]\),*/g;
|
@@ -2264,6 +2266,15 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
2264
2266
|
pendingPromises = [];
|
2265
2267
|
initialize(ctx) {
|
2266
2268
|
const config = ctx.config.coverage;
|
2269
|
+
if (ctx.version !== version) {
|
2270
|
+
ctx.logger.warn(
|
2271
|
+
c.yellow(
|
2272
|
+
`Loaded ${c.inverse(c.yellow(` vitest@${ctx.version} `))} and ${c.inverse(c.yellow(` @vitest/coverage-v8@${version} `))}.
|
2273
|
+
Running mixed versions is not supported and may lead into bugs
|
2274
|
+
Update your dependencies and make sure the versions match.`
|
2275
|
+
)
|
2276
|
+
);
|
2277
|
+
}
|
2267
2278
|
this.ctx = ctx;
|
2268
2279
|
this.options = {
|
2269
2280
|
...coverageConfigDefaults,
|
@@ -2544,31 +2555,34 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
2544
2555
|
}
|
2545
2556
|
const map = transformResult?.map;
|
2546
2557
|
const code = transformResult?.code;
|
2547
|
-
const sourcesContent = map?.sourcesContent
|
2548
|
-
|
2549
|
-
|
2550
|
-
|
2558
|
+
const sourcesContent = map?.sourcesContent || [];
|
2559
|
+
if (!sourcesContent[0]) {
|
2560
|
+
sourcesContent[0] = await promises$1.readFile(filePath, "utf-8").catch(() => {
|
2561
|
+
const length = findLongestFunctionLength(functions);
|
2562
|
+
return ".".repeat(length);
|
2563
|
+
});
|
2564
|
+
}
|
2551
2565
|
if (!map) {
|
2552
2566
|
return {
|
2553
2567
|
isExecuted,
|
2554
|
-
source: code || sourcesContent,
|
2555
|
-
originalSource: sourcesContent
|
2568
|
+
source: code || sourcesContent[0],
|
2569
|
+
originalSource: sourcesContent[0]
|
2556
2570
|
};
|
2557
2571
|
}
|
2558
|
-
const sources = [url
|
2559
|
-
if (
|
2560
|
-
sources
|
2572
|
+
const sources = (map.sources || []).filter((source) => source != null).map((source) => new URL(source, url).href);
|
2573
|
+
if (sources.length === 0) {
|
2574
|
+
sources.push(url);
|
2561
2575
|
}
|
2562
2576
|
return {
|
2563
2577
|
isExecuted,
|
2564
|
-
originalSource: sourcesContent,
|
2565
|
-
source: code || sourcesContent,
|
2578
|
+
originalSource: sourcesContent[0],
|
2579
|
+
source: code || sourcesContent[0],
|
2566
2580
|
sourceMap: {
|
2567
2581
|
sourcemap: excludeGeneratedCode(code, {
|
2568
2582
|
...map,
|
2569
2583
|
version: 3,
|
2570
2584
|
sources,
|
2571
|
-
sourcesContent
|
2585
|
+
sourcesContent
|
2572
2586
|
})
|
2573
2587
|
}
|
2574
2588
|
};
|
@@ -2606,7 +2620,12 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
2606
2620
|
this.options.ignoreEmptyLines
|
2607
2621
|
);
|
2608
2622
|
await converter.load();
|
2609
|
-
|
2623
|
+
try {
|
2624
|
+
converter.applyCoverage(functions);
|
2625
|
+
} catch (error) {
|
2626
|
+
this.ctx.logger.error(`Failed to convert coverage for ${url}.
|
2627
|
+
`, error);
|
2628
|
+
}
|
2610
2629
|
coverageMap.merge(converter.toIstanbul());
|
2611
2630
|
})
|
2612
2631
|
);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/coverage-v8",
|
3
3
|
"type": "module",
|
4
|
-
"version": "2.1.0-beta.
|
4
|
+
"version": "2.1.0-beta.5",
|
5
5
|
"description": "V8 coverage provider for Vitest",
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
7
7
|
"license": "MIT",
|
@@ -37,7 +37,7 @@
|
|
37
37
|
"dist"
|
38
38
|
],
|
39
39
|
"peerDependencies": {
|
40
|
-
"vitest": "2.1.0-beta.
|
40
|
+
"vitest": "2.1.0-beta.5"
|
41
41
|
},
|
42
42
|
"dependencies": {
|
43
43
|
"@ampproject/remapping": "^2.3.0",
|
@@ -61,8 +61,8 @@
|
|
61
61
|
"@types/istanbul-reports": "^3.0.4",
|
62
62
|
"pathe": "^1.1.2",
|
63
63
|
"v8-to-istanbul": "^9.3.0",
|
64
|
-
"
|
65
|
-
"
|
64
|
+
"vitest": "2.1.0-beta.5",
|
65
|
+
"vite-node": "2.1.0-beta.5"
|
66
66
|
},
|
67
67
|
"scripts": {
|
68
68
|
"build": "rimraf dist && rollup -c",
|