@vitest/coverage-v8 1.5.3 → 1.6.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 +9 -3
- package/package.json +4 -4
package/dist/provider.js
CHANGED
@@ -2403,8 +2403,12 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
2403
2403
|
}
|
2404
2404
|
async getSources(url, transformResults, functions = []) {
|
2405
2405
|
const filePath = normalize(fileURLToPath$1(url));
|
2406
|
-
|
2407
|
-
|
2406
|
+
let isExecuted = true;
|
2407
|
+
let transformResult = transformResults.get(filePath);
|
2408
|
+
if (!transformResult) {
|
2409
|
+
isExecuted = false;
|
2410
|
+
transformResult = await this.ctx.vitenode.transformRequest(filePath).catch(() => null);
|
2411
|
+
}
|
2408
2412
|
const map = transformResult?.map;
|
2409
2413
|
const code = transformResult?.code;
|
2410
2414
|
const sourcesContent = map?.sourcesContent?.[0] || await promises$1.readFile(filePath, "utf-8").catch(() => {
|
@@ -2413,6 +2417,7 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
2413
2417
|
});
|
2414
2418
|
if (!map) {
|
2415
2419
|
return {
|
2420
|
+
isExecuted,
|
2416
2421
|
source: code || sourcesContent,
|
2417
2422
|
originalSource: sourcesContent
|
2418
2423
|
};
|
@@ -2421,6 +2426,7 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
2421
2426
|
if (map.sources && map.sources[0] && !url.endsWith(map.sources[0]))
|
2422
2427
|
sources[0] = new URL(map.sources[0], url).href;
|
2423
2428
|
return {
|
2429
|
+
isExecuted,
|
2424
2430
|
originalSource: sourcesContent,
|
2425
2431
|
source: code || sourcesContent,
|
2426
2432
|
sourceMap: {
|
@@ -2447,7 +2453,7 @@ class V8CoverageProvider extends BaseCoverageProvider {
|
|
2447
2453
|
}
|
2448
2454
|
await Promise.all(chunk.map(async ({ url, functions }) => {
|
2449
2455
|
const sources = await this.getSources(url, transformResults, functions);
|
2450
|
-
const wrapperLength = sources.
|
2456
|
+
const wrapperLength = sources.isExecuted ? WRAPPER_LENGTH : 0;
|
2451
2457
|
const converter = v8ToIstanbul$1(url, wrapperLength, sources, void 0, this.options.ignoreEmptyLines);
|
2452
2458
|
await converter.load();
|
2453
2459
|
converter.applyCoverage(functions);
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/coverage-v8",
|
3
3
|
"type": "module",
|
4
|
-
"version": "1.
|
4
|
+
"version": "1.6.1",
|
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": "1.
|
40
|
+
"vitest": "1.6.1"
|
41
41
|
},
|
42
42
|
"dependencies": {
|
43
43
|
"@ampproject/remapping": "^2.2.1",
|
@@ -62,8 +62,8 @@
|
|
62
62
|
"@types/istanbul-reports": "^3.0.4",
|
63
63
|
"pathe": "^1.1.1",
|
64
64
|
"v8-to-istanbul": "^9.2.0",
|
65
|
-
"vite-node": "1.
|
66
|
-
"vitest": "1.
|
65
|
+
"vite-node": "1.6.1",
|
66
|
+
"vitest": "1.6.1"
|
67
67
|
},
|
68
68
|
"scripts": {
|
69
69
|
"build": "rimraf dist && rollup -c",
|