@vitest/coverage-v8 1.2.0 → 1.2.2

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 +19 -3
  2. package/package.json +4 -4
package/dist/provider.js CHANGED
@@ -307,13 +307,13 @@ class V8CoverageProvider extends BaseCoverageProvider {
307
307
  perFile: this.options.thresholds.perFile,
308
308
  configurationFile: {
309
309
  write: () => writeFileSync(configFilePath, configModule.generate().code, "utf-8"),
310
- read: () => configModule.exports.default.$type === "function-call" ? configModule.exports.default.$args[0] : configModule.exports.default
310
+ read: () => resolveConfig(configModule)
311
311
  }
312
312
  });
313
313
  }
314
- this.coverageFiles = /* @__PURE__ */ new Map();
315
- await promises.rm(this.coverageFilesDirectory, { recursive: true });
316
314
  }
315
+ this.coverageFiles = /* @__PURE__ */ new Map();
316
+ await promises.rm(this.coverageFilesDirectory, { recursive: true });
317
317
  }
318
318
  async getUntestedFiles(testedFiles) {
319
319
  const transformResults = normalizeTransformResults(this.ctx.vitenode.fetchCache);
@@ -445,5 +445,21 @@ function toSlices(array, size) {
445
445
  return chunks;
446
446
  }, []);
447
447
  }
448
+ function resolveConfig(configModule) {
449
+ const mod = configModule.exports.default;
450
+ try {
451
+ if (mod.$type === "object")
452
+ return mod;
453
+ if (mod.$type === "function-call") {
454
+ if (mod.$args[0].$type === "object")
455
+ return mod.$args[0];
456
+ if (mod.$args[0].$type === "arrow-function-expression" && mod.$args[0].$body.$type === "object")
457
+ return mod.$args[0].$body;
458
+ }
459
+ } catch (error) {
460
+ throw new Error(error instanceof Error ? error.message : String(error));
461
+ }
462
+ throw new Error("Failed to update coverage thresholds. Configuration file is too complex.");
463
+ }
448
464
 
449
465
  export { V8CoverageProvider };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@vitest/coverage-v8",
3
3
  "type": "module",
4
- "version": "1.2.0",
4
+ "version": "1.2.2",
5
5
  "description": "V8 coverage provider for Vitest",
6
6
  "author": "Anthony Fu <anthonyfu117@hotmail.com>",
7
7
  "license": "MIT",
@@ -48,7 +48,7 @@
48
48
  "istanbul-lib-source-maps": "^4.0.1",
49
49
  "istanbul-reports": "^3.1.6",
50
50
  "magic-string": "^0.30.5",
51
- "magicast": "^0.3.2",
51
+ "magicast": "^0.3.3",
52
52
  "picocolors": "^1.0.0",
53
53
  "std-env": "^3.5.0",
54
54
  "test-exclude": "^6.0.0",
@@ -61,8 +61,8 @@
61
61
  "@types/istanbul-lib-source-maps": "^4.0.4",
62
62
  "@types/istanbul-reports": "^3.0.4",
63
63
  "pathe": "^1.1.1",
64
- "vite-node": "1.2.0",
65
- "vitest": "1.2.0"
64
+ "vite-node": "1.2.2",
65
+ "vitest": "1.2.2"
66
66
  },
67
67
  "scripts": {
68
68
  "build": "rimraf dist && rollup -c",