@vitest/coverage-istanbul 2.0.0-beta.11 → 2.0.0-beta.13

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/index.js CHANGED
@@ -2,7 +2,10 @@ import { C as COVERAGE_STORE_KEY } from './constants-BCJfMgEg.js';
2
2
 
3
3
  async function getProvider() {
4
4
  const providerPath = "./provider.js";
5
- const { IstanbulCoverageProvider } = await import(providerPath);
5
+ const { IstanbulCoverageProvider } = await import(
6
+ /* @vite-ignore */
7
+ providerPath
8
+ );
6
9
  return new IstanbulCoverageProvider();
7
10
  }
8
11
  function takeCoverage() {
package/dist/provider.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { promises, existsSync, readdirSync, writeFileSync } from 'node:fs';
2
- import { coverageConfigDefaults, defaultExclude, defaultInclude } from 'vitest/config';
2
+ import { coverageConfigDefaults } from 'vitest/config';
3
3
  import { BaseCoverageProvider } from 'vitest/coverage';
4
4
  import c from 'picocolors';
5
5
  import { parseModule } from 'magicast';
@@ -9,6 +9,7 @@ import reports from 'istanbul-reports';
9
9
  import libCoverage from 'istanbul-lib-coverage';
10
10
  import libSourceMaps from 'istanbul-lib-source-maps';
11
11
  import { createInstrumenter } from 'istanbul-lib-instrument';
12
+ import { defaults } from '@istanbuljs/schema';
12
13
  import _TestExclude from 'test-exclude';
13
14
  import { C as COVERAGE_STORE_KEY } from './constants-BCJfMgEg.js';
14
15
 
@@ -152,12 +153,19 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
152
153
  // @ts-expect-error missing type
153
154
  coverageGlobalScope: "globalThis",
154
155
  coverageGlobalScopeFunc: false,
155
- ignoreClassMethods: this.options.ignoreClassMethods
156
+ ignoreClassMethods: this.options.ignoreClassMethods,
157
+ parserPlugins: [
158
+ ...defaults.instrumenter.parserPlugins,
159
+ ["importAttributes", { deprecatedAssertSyntax: true }]
160
+ ],
161
+ generatorOpts: {
162
+ importAttributesKeyword: "with"
163
+ }
156
164
  });
157
165
  this.testExclude = new _TestExclude({
158
166
  cwd: ctx.config.root,
159
- include: typeof this.options.include === "undefined" ? void 0 : [...this.options.include],
160
- exclude: [...defaultExclude, ...defaultInclude, ...this.options.exclude],
167
+ include: this.options.include,
168
+ exclude: this.options.exclude,
161
169
  excludeNodeModules: true,
162
170
  extension: this.options.extension,
163
171
  relativePath: !this.options.allowExternal
@@ -318,7 +326,8 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
318
326
  });
319
327
  this.checkThresholds({
320
328
  thresholds: resolvedThresholds,
321
- perFile: this.options.thresholds.perFile
329
+ perFile: this.options.thresholds.perFile,
330
+ onError: (error) => this.ctx.logger.error(error)
322
331
  });
323
332
  if (this.options.thresholds.autoUpdate && allTestsRun) {
324
333
  if (!this.ctx.server.config.configFile) {
@@ -373,33 +382,11 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
373
382
  }
374
383
  }
375
384
  async function transformCoverage(coverageMap) {
376
- includeImplicitElseBranches(coverageMap);
377
385
  const sourceMapStore = libSourceMaps.createSourceMapStore();
378
386
  return await sourceMapStore.transformCoverage(coverageMap);
379
387
  }
380
388
  function removeQueryParameters(filename) {
381
389
  return filename.split("?")[0];
382
390
  }
383
- function includeImplicitElseBranches(coverageMap) {
384
- for (const file of coverageMap.files()) {
385
- const fileCoverage = coverageMap.fileCoverageFor(file);
386
- for (const branchMap of Object.values(fileCoverage.branchMap)) {
387
- if (branchMap.type === "if") {
388
- const lastIndex = branchMap.locations.length - 1;
389
- if (lastIndex > 0) {
390
- const elseLocation = branchMap.locations[lastIndex];
391
- if (elseLocation && isEmptyCoverageRange(elseLocation)) {
392
- const ifLocation = branchMap.locations[0];
393
- elseLocation.start = { ...ifLocation.start };
394
- elseLocation.end = { ...ifLocation.end };
395
- }
396
- }
397
- }
398
- }
399
- }
400
- }
401
- function isEmptyCoverageRange(range) {
402
- 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;
403
- }
404
391
 
405
392
  export { IstanbulCoverageProvider };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/coverage-istanbul",
3
3
  "type": "module",
4
- "version": "2.0.0-beta.11",
4
+ "version": "2.0.0-beta.13",
5
5
  "description": "Istanbul coverage provider for Vitest",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -37,14 +37,15 @@
37
37
  "dist"
38
38
  ],
39
39
  "peerDependencies": {
40
- "vitest": "2.0.0-beta.11"
40
+ "vitest": "2.0.0-beta.13"
41
41
  },
42
42
  "dependencies": {
43
+ "@istanbuljs/schema": "^0.1.3",
43
44
  "debug": "^4.3.5",
44
45
  "istanbul-lib-coverage": "^3.2.2",
45
- "istanbul-lib-instrument": "^6.0.2",
46
+ "istanbul-lib-instrument": "^6.0.3",
46
47
  "istanbul-lib-report": "^3.0.1",
47
- "istanbul-lib-source-maps": "^5.0.4",
48
+ "istanbul-lib-source-maps": "^5.0.6",
48
49
  "istanbul-reports": "^3.1.7",
49
50
  "magicast": "^0.3.4",
50
51
  "picocolors": "^1.0.1",
@@ -58,7 +59,7 @@
58
59
  "@types/istanbul-lib-source-maps": "^4.0.4",
59
60
  "@types/istanbul-reports": "^3.0.4",
60
61
  "pathe": "^1.1.2",
61
- "vitest": "2.0.0-beta.11"
62
+ "vitest": "2.0.0-beta.13"
62
63
  },
63
64
  "scripts": {
64
65
  "build": "rimraf dist && rollup -c",