The coverage gate divided traced counts by hardcoded literals (UR/39, IR/24, DR/48, JA/3, TOTAL_REQS=114) that had fallen out of date as requirements grew to 211. It reported 158% coverage — JA alone printed 800% — so the 50% threshold was mathematically unreachable and the job could not fail. Coverage could have collapsed to 30% and CI would still have printed a green tick. Real coverage is 86%. The number was fine; the gate was dead. extract-traces.ts now owns both sides of the fraction: - countDefinedRequirements() counts an ID only where it leads a markdown table row, ignoring the "Traces To" column and prose. IDs are deduplicated because requirements.md lists every UR twice (§1 definition + §3 matrix), which would otherwise report UR as 121/61. - computeCoverage() uses the intersection of traced and defined IDs, so a TRACES comment naming a deleted or typo'd requirement is reported as `orphaned` rather than inflating the ratio past 100%. UT/IT test identifiers are excluded as a separate taxonomy. - CI reads .coverage.percent and fails on <50% or >100%; a >100% reading is now a hard error rather than the condition that hid this bug. - New `bun run traces:coverage` runs the same computation locally. - scripts/ added to the scan roots — the coverage tool was invisible to the matrix it generates. Tests written first (15, over fixtures so they don't drift as requirements are added). vitest include widened to scripts/** so build tooling is covered by the normal suite. Verified empirically rather than by inspection: forcing the threshold to 99% fails; adding a requirement lowers coverage 86%→85%; a TRACES: DR-999 lands in `orphaned` without changing `covered`. traceability-ci.md documented the same stale numbers and would have let the broken arithmetic be reconstructed — replaced with a pointer to the live command.
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import { defineConfig } from "vitest/config";
|
|
import { svelte } from "@sveltejs/vite-plugin-svelte";
|
|
import { resolve } from "path";
|
|
|
|
export default defineConfig({
|
|
plugins: [svelte({ hot: !process.env.VITEST })],
|
|
test: {
|
|
globals: true,
|
|
environment: "jsdom",
|
|
setupFiles: ["./src/test/setup-globals.ts", "./src/test/setup.ts"],
|
|
// `scripts/` is included so build tooling (the traceability coverage
|
|
// engine) is covered by the normal suite rather than only by CI.
|
|
include: ["src/**/*.{test,spec}.{js,ts}", "scripts/**/*.{test,spec}.{js,ts}"],
|
|
coverage: {
|
|
provider: "v8",
|
|
reporter: ["text", "json", "html"],
|
|
exclude: [
|
|
"node_modules/",
|
|
"src/test/",
|
|
"**/*.test.ts",
|
|
"**/*.spec.ts",
|
|
"src-tauri/",
|
|
],
|
|
},
|
|
},
|
|
resolve: {
|
|
conditions: ["browser"],
|
|
alias: {
|
|
$lib: resolve(__dirname, "./src/lib"),
|
|
"$lib/": resolve(__dirname, "./src/lib/"),
|
|
"$app/environment": resolve(__dirname, "./src/test/mocks/app-environment.ts"),
|
|
"$app/navigation": resolve(__dirname, "./src/test/mocks/app-navigation.ts"),
|
|
"$app/stores": resolve(__dirname, "./src/test/mocks/app-stores.ts"),
|
|
},
|
|
},
|
|
});
|