@cldmv/vitest-runner 1.4.2 → 1.4.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cldmv/vitest-runner",
3
- "version": "1.4.2",
3
+ "version": "1.4.4",
4
4
  "description": "Sequential Vitest runner to avoid OOM issues with large test suites",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -39,7 +39,7 @@
39
39
  "types:check": "tsc -p .configs/tsconfig.json --noEmit",
40
40
  "build": "tsup",
41
41
  "build:ci": "npm run lint && npm run format:check && npm run types:build && npm run build",
42
- "prepack": "node -e \"const fs=require('node:fs');const hasTsup=fs.existsSync('node_modules/.bin/tsup')||fs.existsSync('node_modules/.bin/tsup.cmd');if(hasTsup){require('node:child_process').execSync('npm run build',{stdio:'inherit'})}else if(!fs.existsSync('dist/index.mjs')){throw new Error('dist/ is missing and tsup is unavailable to build it (expected in a bare package-contents publish dir with a prebuilt dist/; unexpected anywhere else)')}\"",
42
+ "prepack": "npm run build",
43
43
  "fix:headers": "node tools/fix-headers.mjs"
44
44
  },
45
45
  "keywords": [
@@ -25,6 +25,10 @@ export function printMergeOutput(exitCode: number, output: string): void;
25
25
  /**
26
26
  * Compute a coverage-summary-style object from a raw V8/Istanbul `coverage-final.json`.
27
27
  *
28
+ * Matches istanbul's own summary: a file with no entries for a metric counts as
29
+ * 100% for that metric, and when there are no files at all every total `pct` is
30
+ * the string `"Unknown"`.
31
+ *
28
32
  * @param {Record<string, object>} finalData - Parsed `coverage-final.json` contents.
29
33
  * @returns {{ total: object, [filePath: string]: object }} Istanbul coverage-summary format.
30
34
  */
@@ -39,6 +43,11 @@ export function computeSummaryFromFinal(finalData: Record<string, object>): {
39
43
  * Tries `coverage-summary.json` first; falls back to computing from
40
44
  * `coverage-final.json` if that is not present.
41
45
  *
46
+ * A non-numeric `pct` (istanbul reports `"Unknown"` when the coverage `include`
47
+ * matched no files) is printed as `Unknown` and never throws. When no files were
48
+ * measured at all, a note says so: there is nothing for a coverage threshold to
49
+ * measure, and vitest's own threshold check does not fail on an `Unknown` value.
50
+ *
42
51
  * @param {string} cwd - Project root (used to make absolute file paths relative).
43
52
  * @param {string[]} extraCoverageArgs - Passthrough `--coverage.*` args (checked for `reportsDirectory`).
44
53
  * @param {number} [worstCount=10] - Number of worst-coverage files to show (0 = skip table).
@@ -46,7 +55,8 @@ export function computeSummaryFromFinal(finalData: Record<string, object>): {
46
55
  * @returns {Promise<{
47
56
  * coverageDir: string,
48
57
  * total: object,
49
- * worstFiles: Array<{file: string, lines: number, stmts: number, fns: number, branches: number}>,
58
+ * noFilesMeasured: boolean,
59
+ * worstFiles: Array<{file: string, lines: number|string, stmts: number|string, fns: number|string, branches: number|string}>,
50
60
  * worstFilesShown: number,
51
61
  * worstFilesTotal: number,
52
62
  * summary: object
@@ -57,12 +67,13 @@ export function printCoverageSummary(cwd: string, extraCoverageArgs: string[], w
57
67
  }): Promise<{
58
68
  coverageDir: string;
59
69
  total: object;
70
+ noFilesMeasured: boolean;
60
71
  worstFiles: Array<{
61
72
  file: string;
62
- lines: number;
63
- stmts: number;
64
- fns: number;
65
- branches: number;
73
+ lines: number | string;
74
+ stmts: number | string;
75
+ fns: number | string;
76
+ branches: number | string;
66
77
  }>;
67
78
  worstFilesShown: number;
68
79
  worstFilesTotal: number;
@@ -22,13 +22,39 @@
22
22
  * stripAnsi('\x1B[32mhello\x1B[0m'); // 'hello'
23
23
  */
24
24
  export function stripAnsi(text: string): string;
25
+ /**
26
+ * Check whether a coverage percentage is a real number.
27
+ *
28
+ * Istanbul reports a metric's `pct` as the string `"Unknown"` when nothing was
29
+ * measured (e.g. the coverage `include` matched no files), so a `pct` cannot be
30
+ * assumed to be numeric.
31
+ * @param {unknown} pct - Coverage percentage as read from a coverage summary.
32
+ * @returns {pct is number} `true` when `pct` is a finite number.
33
+ * @example
34
+ * isKnownPct(75.5); // true
35
+ * isKnownPct("Unknown"); // false
36
+ */
37
+ export function isKnownPct(pct: unknown): pct is number;
38
+ /**
39
+ * Format a coverage percentage with a fixed number of decimals, or `Unknown`
40
+ * when the value is not a number.
41
+ * @param {unknown} pct - Coverage percentage as read from a coverage summary.
42
+ * @param {number} digits - Decimal places for a numeric value.
43
+ * @returns {string} The formatted percentage (without a `%` sign).
44
+ * @example
45
+ * formatPct(75.5, 0); // '76'
46
+ * formatPct("Unknown", 0); // 'Unknown'
47
+ */
48
+ export function formatPct(pct: unknown, digits: number): string;
25
49
  /**
26
50
  * Colour-code a coverage percentage value using chalk.
27
- * ≥ 80 % → green, ≥ 50 % → yellow, < 50 % → red.
51
+ * ≥ 80 % → green, ≥ 50 % → yellow, < 50 % → red. A non-numeric value
52
+ * (istanbul's `"Unknown"`) is rendered as a dim `Unknown`.
28
53
  * @param {import('chalk').ChalkInstance} chalk - Chalk instance supplied by the caller.
29
- * @param {number} pct - Coverage percentage 0–100.
54
+ * @param {unknown} pct - Coverage percentage 0–100, or a non-numeric value such as `"Unknown"`.
30
55
  * @returns {string} Chalk-coloured, right-aligned percentage string.
31
56
  * @example
32
57
  * colourPct(chalk, 75.5); // yellow ' 75.50'
58
+ * colourPct(chalk, "Unknown"); // dim 'Unknown'
33
59
  */
34
- export function colourPct(chalk: import("chalk").ChalkInstance, pct: number): string;
60
+ export function colourPct(chalk: import("chalk").ChalkInstance, pct: unknown): string;