@vitest/coverage-istanbul 0.28.4 → 0.29.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-6c50226e.js');
4
+ const { IstanbulCoverageProvider } = await import('./provider-bca6bd2d.js');
5
5
  return new IstanbulCoverageProvider();
6
6
  }
7
7
  function takeCoverage() {
package/dist/index.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { CoverageProvider, Vitest, AfterSuiteRunMeta, ReportContext, ResolvedCoverageOptions } from 'vitest';
2
+ import { BaseCoverageProvider } from 'vitest/coverage';
2
3
  import { CoverageMap } from 'istanbul-lib-coverage';
3
4
  import { Instrumenter } from 'istanbul-lib-instrument';
4
5
 
@@ -201,7 +202,7 @@ interface TestExclude {
201
202
  glob(cwd: string): Promise<string[]>;
202
203
  };
203
204
  }
204
- declare class IstanbulCoverageProvider implements CoverageProvider {
205
+ declare class IstanbulCoverageProvider extends BaseCoverageProvider implements CoverageProvider {
205
206
  name: string;
206
207
  ctx: Vitest;
207
208
  options: Options;
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- export { g as getProvider, t as takeCoverage } from './index-de988ace.js';
1
+ export { g as getProvider, t as takeCoverage } from './index-f1f55bac.js';
@@ -1,12 +1,13 @@
1
1
  import { existsSync, promises } from 'fs';
2
- import { defaultExclude, defaultInclude, coverageConfigDefaults } from 'vitest/config';
2
+ import { coverageConfigDefaults, defaultExclude, defaultInclude } from 'vitest/config';
3
+ import { BaseCoverageProvider } from 'vitest/coverage';
3
4
  import libReport from 'istanbul-lib-report';
4
5
  import reports from 'istanbul-reports';
5
6
  import libCoverage from 'istanbul-lib-coverage';
6
7
  import libSourceMaps from 'istanbul-lib-source-maps';
7
8
  import { createInstrumenter } from 'istanbul-lib-instrument';
8
9
  import _TestExclude from 'test-exclude';
9
- import { C as COVERAGE_STORE_KEY } from './index-de988ace.js';
10
+ import { C as COVERAGE_STORE_KEY } from './index-f1f55bac.js';
10
11
 
11
12
  function normalizeWindowsPath(input = "") {
12
13
  if (!input || !input.includes("\\")) {
@@ -115,14 +116,22 @@ const relative = function(from, to) {
115
116
  return [..._from.map(() => ".."), ..._to].join("/");
116
117
  };
117
118
 
118
- class IstanbulCoverageProvider {
119
+ class IstanbulCoverageProvider extends BaseCoverageProvider {
119
120
  constructor() {
121
+ super(...arguments);
120
122
  this.name = "istanbul";
121
123
  this.coverages = [];
122
124
  }
123
125
  initialize(ctx) {
126
+ const config = ctx.config.coverage;
124
127
  this.ctx = ctx;
125
- this.options = resolveIstanbulOptions(ctx.config.coverage, ctx.config.root);
128
+ this.options = {
129
+ ...coverageConfigDefaults,
130
+ ...config,
131
+ provider: "istanbul",
132
+ reportsDirectory: resolve(ctx.config.root, config.reportsDirectory || coverageConfigDefaults.reportsDirectory),
133
+ reporter: this.resolveReporters(config.reporter || coverageConfigDefaults.reporter)
134
+ };
126
135
  this.instrumenter = createInstrumenter({
127
136
  produceSourceMap: true,
128
137
  autoWrap: false,
@@ -179,9 +188,10 @@ class IstanbulCoverageProvider {
179
188
  watermarks: this.options.watermarks
180
189
  });
181
190
  for (const reporter of this.options.reporter) {
182
- reports.create(reporter, {
191
+ reports.create(reporter[0], {
183
192
  skipFull: this.options.skipFull,
184
- projectRoot: this.ctx.config.root
193
+ projectRoot: this.ctx.config.root,
194
+ ...reporter[1]
185
195
  }).execute(context);
186
196
  }
187
197
  if (this.options.branches || this.options.functions || this.options.lines || this.options.statements) {
@@ -192,6 +202,18 @@ class IstanbulCoverageProvider {
192
202
  statements: this.options.statements
193
203
  });
194
204
  }
205
+ if (this.options.thresholdAutoUpdate && allTestsRun) {
206
+ this.updateThresholds({
207
+ coverageMap,
208
+ thresholds: {
209
+ branches: this.options.branches,
210
+ functions: this.options.functions,
211
+ lines: this.options.lines,
212
+ statements: this.options.statements
213
+ },
214
+ configurationFile: this.ctx.server.config.configFile
215
+ });
216
+ }
195
217
  }
196
218
  checkThresholds(coverageMap, thresholds) {
197
219
  const summaries = this.options.perFile ? coverageMap.files().map((file) => ({
@@ -242,18 +264,6 @@ class IstanbulCoverageProvider {
242
264
  }
243
265
  }
244
266
  }
245
- function resolveIstanbulOptions(options, root) {
246
- const reportsDirectory = resolve(root, options.reportsDirectory || coverageConfigDefaults.reportsDirectory);
247
- const reporter = options.reporter || coverageConfigDefaults.reporter;
248
- const resolved = {
249
- ...coverageConfigDefaults,
250
- ...options,
251
- provider: "istanbul",
252
- reportsDirectory,
253
- reporter: Array.isArray(reporter) ? reporter : [reporter]
254
- };
255
- return resolved;
256
- }
257
267
  function removeQueryParameters(filename) {
258
268
  return filename.split("?")[0];
259
269
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/coverage-istanbul",
3
3
  "type": "module",
4
- "version": "0.28.4",
4
+ "version": "0.29.0",
5
5
  "description": "Istanbul coverage provider for Vitest",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -36,14 +36,16 @@
36
36
  "files": [
37
37
  "dist"
38
38
  ],
39
+ "peerDependencies": {
40
+ "vitest": ">=0.28.0 <1"
41
+ },
39
42
  "dependencies": {
40
43
  "istanbul-lib-coverage": "^3.2.0",
41
44
  "istanbul-lib-instrument": "^5.2.1",
42
45
  "istanbul-lib-report": "^3.0.0",
43
46
  "istanbul-lib-source-maps": "^4.0.1",
44
47
  "istanbul-reports": "^3.1.5",
45
- "test-exclude": "^6.0.0",
46
- "vitest": "0.28.4"
48
+ "test-exclude": "^6.0.0"
47
49
  },
48
50
  "devDependencies": {
49
51
  "@types/istanbul-lib-coverage": "^2.0.4",
@@ -51,7 +53,8 @@
51
53
  "@types/istanbul-lib-report": "^3.0.0",
52
54
  "@types/istanbul-lib-source-maps": "^4.0.1",
53
55
  "@types/istanbul-reports": "^3.0.1",
54
- "pathe": "^1.1.0"
56
+ "pathe": "^1.1.0",
57
+ "vitest": "0.29.0"
55
58
  },
56
59
  "scripts": {
57
60
  "build": "rimraf dist && rollup -c",