@vitest/coverage-istanbul 4.0.14 → 4.0.16
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 +27 -2
- package/package.json +5 -3
package/dist/provider.js
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { existsSync, promises } from 'node:fs';
|
|
2
2
|
import { defaults } from '@istanbuljs/schema';
|
|
3
|
+
import { GenMapping, addMapping, toEncodedMap } from '@jridgewell/gen-mapping';
|
|
4
|
+
import { eachMapping, TraceMap } from '@jridgewell/trace-mapping';
|
|
3
5
|
import libCoverage from 'istanbul-lib-coverage';
|
|
4
6
|
import { createInstrumenter } from 'istanbul-lib-instrument';
|
|
5
7
|
import libReport from 'istanbul-lib-report';
|
|
@@ -12,7 +14,7 @@ import { BaseCoverageProvider } from 'vitest/coverage';
|
|
|
12
14
|
import { isCSSRequest } from 'vitest/node';
|
|
13
15
|
import { C as COVERAGE_STORE_KEY } from './constants-BCJfMgEg.js';
|
|
14
16
|
|
|
15
|
-
var version = "4.0.
|
|
17
|
+
var version = "4.0.16";
|
|
16
18
|
|
|
17
19
|
const debug = createDebug("vitest:coverage");
|
|
18
20
|
class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
@@ -55,6 +57,29 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
|
55
57
|
sourceMap.sources = sourceMap.sources.map(removeQueryParameters);
|
|
56
58
|
sourceCode = sourceCode.replaceAll("_ts_decorate", "/* istanbul ignore next */_ts_decorate").replaceAll(/(if +\(import\.meta\.vitest\))/g, "/* istanbul ignore next */ $1");
|
|
57
59
|
const code = this.instrumenter.instrumentSync(sourceCode, id, sourceMap);
|
|
60
|
+
if (!id.includes("vitest-uncovered-coverage=true")) {
|
|
61
|
+
const transformMap = new GenMapping(sourceMap);
|
|
62
|
+
eachMapping(new TraceMap(sourceMap), (mapping) => {
|
|
63
|
+
addMapping(transformMap, {
|
|
64
|
+
generated: {
|
|
65
|
+
line: mapping.generatedLine,
|
|
66
|
+
column: mapping.generatedColumn
|
|
67
|
+
},
|
|
68
|
+
original: {
|
|
69
|
+
line: mapping.generatedLine,
|
|
70
|
+
column: mapping.generatedColumn
|
|
71
|
+
},
|
|
72
|
+
content: sourceCode,
|
|
73
|
+
name: mapping.name || "",
|
|
74
|
+
source: mapping.source || ""
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
const encodedMap = toEncodedMap(transformMap);
|
|
78
|
+
delete encodedMap.file;
|
|
79
|
+
delete encodedMap.ignoreList;
|
|
80
|
+
delete encodedMap.sourceRoot;
|
|
81
|
+
this.instrumenter.instrumentSync(sourceCode, id, encodedMap);
|
|
82
|
+
}
|
|
58
83
|
const map = this.instrumenter.lastSourceMap();
|
|
59
84
|
this.transformedModuleIds.add(id);
|
|
60
85
|
return {
|
|
@@ -141,7 +166,7 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
|
141
166
|
debug("Uncovered file %d/%d", index, uncoveredFiles.length);
|
|
142
167
|
}
|
|
143
168
|
// Make sure file is not served from cache so that instrumenter loads up requested file coverage
|
|
144
|
-
await transform(`${filename}?cache=${cacheKey}`);
|
|
169
|
+
await transform(`${filename}?cache=${cacheKey}&vitest-uncovered-coverage=true`);
|
|
145
170
|
const lastCoverage = this.instrumenter.lastFileCoverage();
|
|
146
171
|
coverageMap.addFileCoverage(lastCoverage);
|
|
147
172
|
if (debug.enabled) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitest/coverage-istanbul",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.16",
|
|
5
5
|
"description": "Istanbul coverage provider for Vitest",
|
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
|
7
7
|
"license": "MIT",
|
|
@@ -37,10 +37,12 @@
|
|
|
37
37
|
"dist"
|
|
38
38
|
],
|
|
39
39
|
"peerDependencies": {
|
|
40
|
-
"vitest": "4.0.
|
|
40
|
+
"vitest": "4.0.16"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@istanbuljs/schema": "^0.1.3",
|
|
44
|
+
"@jridgewell/gen-mapping": "^0.3.13",
|
|
45
|
+
"@jridgewell/trace-mapping": "0.3.31",
|
|
44
46
|
"istanbul-lib-coverage": "^3.2.2",
|
|
45
47
|
"istanbul-lib-instrument": "^6.0.3",
|
|
46
48
|
"istanbul-lib-report": "^3.0.1",
|
|
@@ -57,7 +59,7 @@
|
|
|
57
59
|
"@types/istanbul-lib-source-maps": "^4.0.4",
|
|
58
60
|
"@types/istanbul-reports": "^3.0.4",
|
|
59
61
|
"pathe": "^2.0.3",
|
|
60
|
-
"vitest": "4.0.
|
|
62
|
+
"vitest": "4.0.16"
|
|
61
63
|
},
|
|
62
64
|
"scripts": {
|
|
63
65
|
"build": "premove dist && rollup -c",
|