@savvy-web/vitest 1.0.0 → 1.1.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.
- package/README.md +10 -0
- package/index.d.ts +24 -2
- package/index.js +20 -1
- package/package.json +6 -3
package/README.md
CHANGED
|
@@ -32,8 +32,18 @@ import { VitestConfig } from "@savvy-web/vitest";
|
|
|
32
32
|
|
|
33
33
|
// Zero config -- everything automatic
|
|
34
34
|
export default VitestConfig.create();
|
|
35
|
+
|
|
36
|
+
// Set coverage thresholds and targets
|
|
37
|
+
export default VitestConfig.create({
|
|
38
|
+
coverage: "standard",
|
|
39
|
+
coverageTargets: "strict",
|
|
40
|
+
});
|
|
35
41
|
```
|
|
36
42
|
|
|
43
|
+
Out of the box, `coverage` defaults to `"none"` (tests never fail due to
|
|
44
|
+
coverage) and `coverageTargets` defaults to `"basic"` (the agent reporter
|
|
45
|
+
highlights coverage gaps without blocking CI).
|
|
46
|
+
|
|
37
47
|
## Directory Structure
|
|
38
48
|
|
|
39
49
|
```text
|
package/index.d.ts
CHANGED
|
@@ -226,9 +226,16 @@ export declare class VitestConfig {
|
|
|
226
226
|
* Resolves coverage thresholds from options.
|
|
227
227
|
*
|
|
228
228
|
* @privateRemarks
|
|
229
|
-
* Priority: `options.coverage` (name or object) \> `COVERAGE_LEVELS.
|
|
229
|
+
* Priority: `options.coverage` (name or object) \> `COVERAGE_LEVELS.none`.
|
|
230
230
|
*/
|
|
231
231
|
private static resolveThresholds;
|
|
232
|
+
/**
|
|
233
|
+
* Resolves coverage targets from options.
|
|
234
|
+
*
|
|
235
|
+
* @privateRemarks
|
|
236
|
+
* Priority: `options.coverageTargets` (name or object) \> `COVERAGE_LEVELS.basic`.
|
|
237
|
+
*/
|
|
238
|
+
private static resolveTargets;
|
|
232
239
|
/**
|
|
233
240
|
* Generates coverage configuration including thresholds.
|
|
234
241
|
*
|
|
@@ -255,9 +262,24 @@ export declare interface VitestConfigOptions {
|
|
|
255
262
|
* preset from {@link VitestConfig.COVERAGE_LEVELS} is used. When a
|
|
256
263
|
* {@link CoverageThresholds} object is provided, it is used directly.
|
|
257
264
|
*
|
|
258
|
-
* @defaultValue `"
|
|
265
|
+
* @defaultValue `"none"` (lines: 0, branches: 0, functions: 0, statements: 0)
|
|
259
266
|
*/
|
|
260
267
|
coverage?: CoverageLevelName | CoverageThresholds;
|
|
268
|
+
/**
|
|
269
|
+
* Coverage targets communicated to `vitest-agent-reporter`.
|
|
270
|
+
*
|
|
271
|
+
* @remarks
|
|
272
|
+
* Targets inform the reporter where coverage gaps exist but do **not**
|
|
273
|
+
* cause test failures. When the agent reporter is enabled, these
|
|
274
|
+
* thresholds are forwarded to the plugin's `reporter.coverageTargets`.
|
|
275
|
+
*
|
|
276
|
+
* If {@link VitestConfigOptions.agentReporter | agentReporter} is an
|
|
277
|
+
* object with its own `reporter.coverageTargets`, the explicit plugin
|
|
278
|
+
* option takes precedence and a warning is logged.
|
|
279
|
+
*
|
|
280
|
+
* @defaultValue `"basic"` (lines: 50, branches: 50, functions: 50, statements: 50)
|
|
281
|
+
*/
|
|
282
|
+
coverageTargets?: CoverageLevelName | CoverageThresholds;
|
|
261
283
|
/** Additional glob patterns to exclude from coverage reporting. */
|
|
262
284
|
coverageExclude?: string[];
|
|
263
285
|
/**
|
package/index.js
CHANGED
|
@@ -215,6 +215,9 @@ class VitestConfig {
|
|
|
215
215
|
};
|
|
216
216
|
if (options?.agentReporter !== false) {
|
|
217
217
|
const agentOpts = "object" == typeof options?.agentReporter ? options.agentReporter : {};
|
|
218
|
+
const targets = VitestConfig.resolveTargets(options);
|
|
219
|
+
const hasExplicitTargets = agentOpts.reporter?.coverageTargets !== void 0;
|
|
220
|
+
if (hasExplicitTargets && options?.coverageTargets !== void 0) console.warn("[@savvy-web/vitest] Both top-level coverageTargets and agentReporter.reporter.coverageTargets are set. Using agentReporter.reporter.coverageTargets.");
|
|
218
221
|
const plugin = AgentPlugin({
|
|
219
222
|
strategy: "own",
|
|
220
223
|
...agentOpts,
|
|
@@ -222,6 +225,11 @@ class VitestConfig {
|
|
|
222
225
|
coverageThresholds: {
|
|
223
226
|
...thresholds
|
|
224
227
|
},
|
|
228
|
+
...!hasExplicitTargets ? {
|
|
229
|
+
coverageTargets: {
|
|
230
|
+
...targets
|
|
231
|
+
}
|
|
232
|
+
} : {},
|
|
225
233
|
...agentOpts.reporter
|
|
226
234
|
}
|
|
227
235
|
});
|
|
@@ -461,7 +469,7 @@ class VitestConfig {
|
|
|
461
469
|
}
|
|
462
470
|
static resolveThresholds(options) {
|
|
463
471
|
if (options?.coverage === void 0) return {
|
|
464
|
-
...VitestConfig.COVERAGE_LEVELS.
|
|
472
|
+
...VitestConfig.COVERAGE_LEVELS.none
|
|
465
473
|
};
|
|
466
474
|
if ("string" == typeof options.coverage) return {
|
|
467
475
|
...VitestConfig.COVERAGE_LEVELS[options.coverage]
|
|
@@ -470,6 +478,17 @@ class VitestConfig {
|
|
|
470
478
|
...options.coverage
|
|
471
479
|
};
|
|
472
480
|
}
|
|
481
|
+
static resolveTargets(options) {
|
|
482
|
+
if (options?.coverageTargets === void 0) return {
|
|
483
|
+
...VitestConfig.COVERAGE_LEVELS.basic
|
|
484
|
+
};
|
|
485
|
+
if ("string" == typeof options.coverageTargets) return {
|
|
486
|
+
...VitestConfig.COVERAGE_LEVELS[options.coverageTargets]
|
|
487
|
+
};
|
|
488
|
+
return {
|
|
489
|
+
...options.coverageTargets
|
|
490
|
+
};
|
|
491
|
+
}
|
|
473
492
|
static getCoverageConfig(specificProjects, projects, options) {
|
|
474
493
|
const exclude = [
|
|
475
494
|
...VitestConfig.DEFAULT_COVERAGE_EXCLUDE,
|
package/package.json
CHANGED
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@savvy-web/vitest",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "Vitest utility functions for Silk Suite deployment system",
|
|
6
6
|
"homepage": "https://github.com/savvy-web/vitest#readme",
|
|
7
|
+
"bugs": {
|
|
8
|
+
"url": "https://github.com/savvy-web/vitest/issues"
|
|
9
|
+
},
|
|
7
10
|
"repository": {
|
|
8
11
|
"type": "git",
|
|
9
12
|
"url": "https://github.com/savvy-web/vitest.git"
|
|
@@ -22,7 +25,7 @@
|
|
|
22
25
|
}
|
|
23
26
|
},
|
|
24
27
|
"dependencies": {
|
|
25
|
-
"workspace-tools": "
|
|
28
|
+
"workspace-tools": "0.41.0"
|
|
26
29
|
},
|
|
27
30
|
"peerDependencies": {
|
|
28
31
|
"@types/node": "^25.5.0",
|
|
@@ -30,7 +33,7 @@
|
|
|
30
33
|
"@vitest/coverage-v8": "^4.1.0",
|
|
31
34
|
"typescript": "^5.9.3",
|
|
32
35
|
"vitest": "^4.1.0",
|
|
33
|
-
"vitest-agent-reporter": "^1.
|
|
36
|
+
"vitest-agent-reporter": "^1.1.0"
|
|
34
37
|
},
|
|
35
38
|
"peerDependenciesMeta": {
|
|
36
39
|
"@types/node": {
|