@vitest/coverage-istanbul 0.31.4 → 0.32.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.
- package/dist/provider.d.ts +0 -2
- package/dist/provider.js +9 -45
- package/package.json +3 -3
package/dist/provider.d.ts
CHANGED
@@ -4,7 +4,6 @@ import { CoverageMap } from 'istanbul-lib-coverage';
|
|
4
4
|
import { Instrumenter } from 'istanbul-lib-instrument';
|
5
5
|
|
6
6
|
type Options = ResolvedCoverageOptions<'istanbul'>;
|
7
|
-
type Threshold = 'lines' | 'functions' | 'statements' | 'branches';
|
8
7
|
interface TestExclude {
|
9
8
|
new (opts: {
|
10
9
|
cwd?: string | string[];
|
@@ -39,7 +38,6 @@ declare class IstanbulCoverageProvider extends BaseCoverageProvider implements C
|
|
39
38
|
onAfterSuiteRun({ coverage }: AfterSuiteRunMeta): void;
|
40
39
|
clean(clean?: boolean): Promise<void>;
|
41
40
|
reportCoverage({ allTestsRun }?: ReportContext): Promise<void>;
|
42
|
-
checkThresholds(coverageMap: CoverageMap, thresholds: Record<Threshold, number | undefined>): void;
|
43
41
|
includeUntestedFiles(coverageMap: CoverageMap): Promise<void>;
|
44
42
|
}
|
45
43
|
|
package/dist/provider.js
CHANGED
@@ -102,19 +102,6 @@ function normalizeString(path, allowAboveRoot) {
|
|
102
102
|
const isAbsolute = function(p) {
|
103
103
|
return _IS_ABSOLUTE_RE.test(p);
|
104
104
|
};
|
105
|
-
const relative = function(from, to) {
|
106
|
-
const _from = resolve(from).split("/");
|
107
|
-
const _to = resolve(to).split("/");
|
108
|
-
const _fromCopy = [..._from];
|
109
|
-
for (const segment of _fromCopy) {
|
110
|
-
if (_to[0] !== segment) {
|
111
|
-
break;
|
112
|
-
}
|
113
|
-
_from.shift();
|
114
|
-
_to.shift();
|
115
|
-
}
|
116
|
-
return [..._from.map(() => ".."), ..._to].join("/");
|
117
|
-
};
|
118
105
|
|
119
106
|
class IstanbulCoverageProvider extends BaseCoverageProvider {
|
120
107
|
constructor() {
|
@@ -204,11 +191,15 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
204
191
|
}).execute(context);
|
205
192
|
}
|
206
193
|
if (this.options.branches || this.options.functions || this.options.lines || this.options.statements) {
|
207
|
-
this.checkThresholds(
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
194
|
+
this.checkThresholds({
|
195
|
+
coverageMap,
|
196
|
+
thresholds: {
|
197
|
+
branches: this.options.branches,
|
198
|
+
functions: this.options.functions,
|
199
|
+
lines: this.options.lines,
|
200
|
+
statements: this.options.statements
|
201
|
+
},
|
202
|
+
perFile: this.options.perFile
|
212
203
|
});
|
213
204
|
}
|
214
205
|
if (this.options.thresholdAutoUpdate && allTestsRun) {
|
@@ -225,33 +216,6 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
|
|
225
216
|
});
|
226
217
|
}
|
227
218
|
}
|
228
|
-
checkThresholds(coverageMap, thresholds) {
|
229
|
-
const summaries = this.options.perFile ? coverageMap.files().map((file) => ({
|
230
|
-
file,
|
231
|
-
summary: coverageMap.fileCoverageFor(file).toSummary()
|
232
|
-
})) : [{
|
233
|
-
file: null,
|
234
|
-
summary: coverageMap.getCoverageSummary()
|
235
|
-
}];
|
236
|
-
for (const { summary, file } of summaries) {
|
237
|
-
for (const thresholdKey of ["lines", "functions", "statements", "branches"]) {
|
238
|
-
const threshold = thresholds[thresholdKey];
|
239
|
-
if (threshold !== void 0) {
|
240
|
-
const coverage = summary.data[thresholdKey].pct;
|
241
|
-
if (coverage < threshold) {
|
242
|
-
process.exitCode = 1;
|
243
|
-
let errorMessage = `ERROR: Coverage for ${thresholdKey} (${coverage}%) does not meet`;
|
244
|
-
if (!this.options.perFile)
|
245
|
-
errorMessage += " global";
|
246
|
-
errorMessage += ` threshold (${threshold}%)`;
|
247
|
-
if (this.options.perFile && file)
|
248
|
-
errorMessage += ` for ${relative("./", file).replace(/\\/g, "/")}`;
|
249
|
-
console.error(errorMessage);
|
250
|
-
}
|
251
|
-
}
|
252
|
-
}
|
253
|
-
}
|
254
|
-
}
|
255
219
|
async includeUntestedFiles(coverageMap) {
|
256
220
|
const includedFiles = await this.testExclude.glob(this.ctx.config.root);
|
257
221
|
const uncoveredFiles = includedFiles.map((file) => resolve(this.ctx.config.root, file)).filter((file) => !coverageMap.data[file]);
|
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.32.0",
|
5
5
|
"description": "Istanbul 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": ">=0.
|
40
|
+
"vitest": ">=0.32.0 <1"
|
41
41
|
},
|
42
42
|
"dependencies": {
|
43
43
|
"istanbul-lib-coverage": "^3.2.0",
|
@@ -54,7 +54,7 @@
|
|
54
54
|
"@types/istanbul-lib-source-maps": "^4.0.1",
|
55
55
|
"@types/istanbul-reports": "^3.0.1",
|
56
56
|
"pathe": "^1.1.0",
|
57
|
-
"vitest": "0.
|
57
|
+
"vitest": "0.32.0"
|
58
58
|
},
|
59
59
|
"scripts": {
|
60
60
|
"build": "rimraf dist && rollup -c",
|