Files
HealthLog/vitest.mutation.config.mts
T
Marc-André Bombeck f5d4dd2ec6 test: mutation testing on the core libraries with per-module floors
Stryker runs against encryption at rest, medication compliance, the rollups,
source ranking, unit conversion and backup validation, with the unit tests
that live next to them (vitest.mutation.config.mts). It is too slow for a
pull request and runs nightly and on demand (.github/workflows/mutation.yml).
scripts/mutation-floors.mjs reads the JSON report and fails when a module
scores below its floor in stryker.floors.json, so one well-tested module
cannot hide a weak one. The floors sit two points below the first measured
scores: crypto 46.9 %, compliance 66.8 %, rollups 41.7 %, source ranking
57.0 %, units 87.4 %, backup validation 25.5 %.

@stryker-mutator/vitest-runner 10.0.0 predates Vitest 5, which names a test
"describe > test" where the runner still built "describe test". Every test
inside a describe block was filtered out of the mutant runs, so nearly every
mutant survived (5.5 % across the set). A pnpm patch builds the name the way
Vitest 5 does; the Docker dependency stage copies the patches directory,
which the frozen install needs.
2026-10-22 06:08:20 +02:00

37 lines
1.2 KiB
TypeScript

import { defineConfig } from "vitest/config";
import { dirname, resolve } from "node:path";
import { fileURLToPath } from "node:url";
const __dirname = dirname(fileURLToPath(import.meta.url));
/**
* The unit tests Stryker runs against each mutant (see `stryker.config.mjs`):
* the tests that live next to the mutated modules, property tests included.
* Kept narrow on purpose, because Stryker runs this set once to map coverage
* and then the covering tests once per mutant. Same environment as the unit
* suite (`vitest.config.mts`): UTC host zone, the same setup file.
*/
export default defineConfig({
test: {
globals: true,
environment: "node",
env: { TZ: "UTC" },
setupFiles: ["./vitest.setup.ts"],
include: [
"src/lib/__tests__/crypto*.test.ts",
"src/lib/analytics/compliance/__tests__/**/*.test.ts",
"src/lib/rollups/__tests__/**/*.test.ts",
"src/lib/analytics/__tests__/source-*.test.ts",
"src/lib/measurements/__tests__/display-transform*.test.ts",
"src/lib/measurements/__tests__/units.property.test.ts",
"src/lib/__tests__/glucose*.test.ts",
"src/lib/validations/__tests__/backup*.test.ts",
],
},
resolve: {
alias: {
"@": resolve(__dirname, "src"),
},
},
});