@vitest/coverage-v8 1.5.3 → 2.0.0-beta.1

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.
Files changed (2) hide show
  1. package/dist/provider.js +13 -6
  2. package/package.json +11 -11
package/dist/provider.js CHANGED
@@ -2056,11 +2056,12 @@ var v8ToIstanbul = function (path, wrapperLength, sources, excludePath, excludeE
2056
2056
 
2057
2057
  var v8ToIstanbul$1 = /*@__PURE__*/getDefaultExportFromCjs(v8ToIstanbul);
2058
2058
 
2059
+ const _DRIVE_LETTER_START_RE = /^[A-Za-z]:\//;
2059
2060
  function normalizeWindowsPath(input = "") {
2060
- if (!input || !input.includes("\\")) {
2061
+ if (!input) {
2061
2062
  return input;
2062
2063
  }
2063
- return input.replace(/\\/g, "/");
2064
+ return input.replace(/\\/g, "/").replace(_DRIVE_LETTER_START_RE, (r) => r.toUpperCase());
2064
2065
  }
2065
2066
 
2066
2067
  const _UNC_REGEX = /^[/\\]{2}/;
@@ -2096,7 +2097,7 @@ const normalize = function(path) {
2096
2097
  return isPathAbsolute && !isAbsolute(path) ? `/${path}` : path;
2097
2098
  };
2098
2099
  function cwd() {
2099
- if (typeof process !== "undefined") {
2100
+ if (typeof process !== "undefined" && typeof process.cwd === "function") {
2100
2101
  return process.cwd().replace(/\\/g, "/");
2101
2102
  }
2102
2103
  return "/";
@@ -2403,8 +2404,12 @@ class V8CoverageProvider extends BaseCoverageProvider {
2403
2404
  }
2404
2405
  async getSources(url, transformResults, functions = []) {
2405
2406
  const filePath = normalize(fileURLToPath$1(url));
2406
- const transformResult = transformResults.get(filePath) || await this.ctx.vitenode.transformRequest(filePath).catch(() => {
2407
- });
2407
+ let isExecuted = true;
2408
+ let transformResult = transformResults.get(filePath);
2409
+ if (!transformResult) {
2410
+ isExecuted = false;
2411
+ transformResult = await this.ctx.vitenode.transformRequest(filePath).catch(() => null);
2412
+ }
2408
2413
  const map = transformResult?.map;
2409
2414
  const code = transformResult?.code;
2410
2415
  const sourcesContent = map?.sourcesContent?.[0] || await promises$1.readFile(filePath, "utf-8").catch(() => {
@@ -2413,6 +2418,7 @@ class V8CoverageProvider extends BaseCoverageProvider {
2413
2418
  });
2414
2419
  if (!map) {
2415
2420
  return {
2421
+ isExecuted,
2416
2422
  source: code || sourcesContent,
2417
2423
  originalSource: sourcesContent
2418
2424
  };
@@ -2421,6 +2427,7 @@ class V8CoverageProvider extends BaseCoverageProvider {
2421
2427
  if (map.sources && map.sources[0] && !url.endsWith(map.sources[0]))
2422
2428
  sources[0] = new URL(map.sources[0], url).href;
2423
2429
  return {
2430
+ isExecuted,
2424
2431
  originalSource: sourcesContent,
2425
2432
  source: code || sourcesContent,
2426
2433
  sourceMap: {
@@ -2447,7 +2454,7 @@ class V8CoverageProvider extends BaseCoverageProvider {
2447
2454
  }
2448
2455
  await Promise.all(chunk.map(async ({ url, functions }) => {
2449
2456
  const sources = await this.getSources(url, transformResults, functions);
2450
- const wrapperLength = sources.sourceMap ? WRAPPER_LENGTH : 0;
2457
+ const wrapperLength = sources.isExecuted ? WRAPPER_LENGTH : 0;
2451
2458
  const converter = v8ToIstanbul$1(url, wrapperLength, sources, void 0, this.options.ignoreEmptyLines);
2452
2459
  await converter.load();
2453
2460
  converter.applyCoverage(functions);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/coverage-v8",
3
3
  "type": "module",
4
- "version": "1.5.3",
4
+ "version": "2.0.0-beta.1",
5
5
  "description": "V8 coverage provider for Vitest",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -37,21 +37,21 @@
37
37
  "dist"
38
38
  ],
39
39
  "peerDependencies": {
40
- "vitest": "1.5.3"
40
+ "vitest": "2.0.0-beta.1"
41
41
  },
42
42
  "dependencies": {
43
- "@ampproject/remapping": "^2.2.1",
43
+ "@ampproject/remapping": "^2.3.0",
44
44
  "@bcoe/v8-coverage": "^0.2.3",
45
45
  "debug": "^4.3.4",
46
46
  "istanbul-lib-coverage": "^3.2.2",
47
47
  "istanbul-lib-report": "^3.0.1",
48
48
  "istanbul-lib-source-maps": "^5.0.4",
49
- "istanbul-reports": "^3.1.6",
50
- "magic-string": "^0.30.5",
51
- "magicast": "^0.3.3",
49
+ "istanbul-reports": "^3.1.7",
50
+ "magic-string": "^0.30.10",
51
+ "magicast": "^0.3.4",
52
52
  "picocolors": "^1.0.0",
53
- "std-env": "^3.5.0",
54
- "strip-literal": "^2.0.0",
53
+ "std-env": "^3.7.0",
54
+ "strip-literal": "^2.1.0",
55
55
  "test-exclude": "^6.0.0"
56
56
  },
57
57
  "devDependencies": {
@@ -60,10 +60,10 @@
60
60
  "@types/istanbul-lib-report": "^3.0.3",
61
61
  "@types/istanbul-lib-source-maps": "^4.0.4",
62
62
  "@types/istanbul-reports": "^3.0.4",
63
- "pathe": "^1.1.1",
63
+ "pathe": "^1.1.2",
64
64
  "v8-to-istanbul": "^9.2.0",
65
- "vite-node": "1.5.3",
66
- "vitest": "1.5.3"
65
+ "vitest": "2.0.0-beta.1",
66
+ "vite-node": "2.0.0-beta.1"
67
67
  },
68
68
  "scripts": {
69
69
  "build": "rimraf dist && rollup -c",