@vitest/coverage-istanbul 0.24.5 → 0.25.0
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.
@@ -1,7 +1,7 @@
|
|
1
1
|
const COVERAGE_STORE_KEY = "__VITEST_COVERAGE__";
|
2
2
|
|
3
3
|
async function getProvider() {
|
4
|
-
const { IstanbulCoverageProvider } = await import('./provider-
|
4
|
+
const { IstanbulCoverageProvider } = await import('./provider-16ea1f6a.js');
|
5
5
|
return new IstanbulCoverageProvider();
|
6
6
|
}
|
7
7
|
function takeCoverage() {
|
package/dist/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export { g as getProvider, t as takeCoverage } from './index-
|
1
|
+
export { g as getProvider, t as takeCoverage } from './index-fae54712.js';
|
@@ -7,7 +7,7 @@ import libCoverage from 'istanbul-lib-coverage';
|
|
7
7
|
import libSourceMaps from 'istanbul-lib-source-maps';
|
8
8
|
import { createInstrumenter } from 'istanbul-lib-instrument';
|
9
9
|
import _TestExclude from 'test-exclude';
|
10
|
-
import { C as COVERAGE_STORE_KEY } from './index-
|
10
|
+
import { C as COVERAGE_STORE_KEY } from './index-fae54712.js';
|
11
11
|
|
12
12
|
function normalizeWindowsPath(input = "") {
|
13
13
|
if (!input.includes("\\")) {
|
@@ -246,6 +246,7 @@ class IstanbulCoverageProvider {
|
|
246
246
|
}, {});
|
247
247
|
if (this.options.all)
|
248
248
|
await this.includeUntestedFiles(mergedCoverage);
|
249
|
+
includeImplicitElseBranches(mergedCoverage);
|
249
250
|
const sourceMapStore = libSourceMaps.createSourceMapStore();
|
250
251
|
const coverageMap = await sourceMapStore.transformCoverage(mergedCoverage);
|
251
252
|
const context = libReport.createContext({
|
@@ -333,5 +334,26 @@ function resolveIstanbulOptions(options, root) {
|
|
333
334
|
function removeQueryParameters(filename) {
|
334
335
|
return filename.split("?")[0];
|
335
336
|
}
|
337
|
+
function includeImplicitElseBranches(coverageMap) {
|
338
|
+
for (const file of coverageMap.files()) {
|
339
|
+
const fileCoverage = coverageMap.fileCoverageFor(file);
|
340
|
+
for (const branchMap of Object.values(fileCoverage.branchMap)) {
|
341
|
+
if (branchMap.type === "if") {
|
342
|
+
const lastIndex = branchMap.locations.length - 1;
|
343
|
+
if (lastIndex > 0) {
|
344
|
+
const elseLocation = branchMap.locations[lastIndex];
|
345
|
+
if (elseLocation && isEmptyCoverageRange(elseLocation)) {
|
346
|
+
const ifLocation = branchMap.locations[0];
|
347
|
+
elseLocation.start = { ...ifLocation.start };
|
348
|
+
elseLocation.end = { ...ifLocation.end };
|
349
|
+
}
|
350
|
+
}
|
351
|
+
}
|
352
|
+
}
|
353
|
+
}
|
354
|
+
}
|
355
|
+
function isEmptyCoverageRange(range) {
|
356
|
+
return range.start === void 0 || range.start.line === void 0 || range.start.column === void 0 || range.end === void 0 || range.end.line === void 0 || range.end.column === void 0;
|
357
|
+
}
|
336
358
|
|
337
359
|
export { IstanbulCoverageProvider };
|
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "@vitest/coverage-istanbul",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.
|
4
|
+
"version": "0.25.0",
|
5
5
|
"description": "Istanbul coverage provider for Vitest",
|
6
6
|
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
|
7
7
|
"license": "MIT",
|
@@ -43,7 +43,7 @@
|
|
43
43
|
"istanbul-lib-source-maps": "^4.0.1",
|
44
44
|
"istanbul-reports": "^3.1.5",
|
45
45
|
"test-exclude": "^6.0.0",
|
46
|
-
"vitest": "0.
|
46
|
+
"vitest": "0.25.0"
|
47
47
|
},
|
48
48
|
"devDependencies": {
|
49
49
|
"@types/istanbul-lib-coverage": "^2.0.4",
|