@vitest/coverage-istanbul 2.0.0-beta.12 → 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
@@ -374,33 +382,11 @@ class IstanbulCoverageProvider extends BaseCoverageProvider {
374
382
  }
375
383
  }
376
384
  async function transformCoverage(coverageMap) {
377
- includeImplicitElseBranches(coverageMap);
378
385
  const sourceMapStore = libSourceMaps.createSourceMapStore();
379
386
  return await sourceMapStore.transformCoverage(coverageMap);
380
387
  }
381
388
  function removeQueryParameters(filename) {
382
389
  return filename.split("?")[0];
383
390
  }
384
- function includeImplicitElseBranches(coverageMap) {
385
- for (const file of coverageMap.files()) {
386
- const fileCoverage = coverageMap.fileCoverageFor(file);
387
- for (const branchMap of Object.values(fileCoverage.branchMap)) {
388
- if (branchMap.type === "if") {
389
- const lastIndex = branchMap.locations.length - 1;
390
- if (lastIndex > 0) {
391
- const elseLocation = branchMap.locations[lastIndex];
392
- if (elseLocation && isEmptyCoverageRange(elseLocation)) {
393
- const ifLocation = branchMap.locations[0];
394
- elseLocation.start = { ...ifLocation.start };
395
- elseLocation.end = { ...ifLocation.end };
396
- }
397
- }
398
- }
399
- }
400
- }
401
- }
402
- function isEmptyCoverageRange(range) {
403
- 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;
404
- }
405
391
 
406
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.12",
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.12"
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.12"
62
+ "vitest": "2.0.0-beta.13"
62
63
  },
63
64
  "scripts": {
64
65
  "build": "rimraf dist && rollup -c",