mirror of
https://github.com/MBombeck/HealthLog.git
synced 2026-11-07 04:12:04 +00:00
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.
49 lines
2.3 KiB
Diff
49 lines
2.3 KiB
Diff
diff --git a/dist/src/stryker-setup.js b/dist/src/stryker-setup.js
|
|
index aecfacbe47b285c272c47e54b3d66a716adfdc41..a6864060e466a4dde49f6d32d9fa8bc8e416baaa 100644
|
|
--- a/dist/src/stryker-setup.js
|
|
+++ b/dist/src/stryker-setup.js
|
|
@@ -57,13 +57,17 @@ else {
|
|
}
|
|
// Stryker disable all: this file is copied to the sandbox dir
|
|
function collectTestName({ name, suite, }) {
|
|
+ // Vitest 5 joins a test's full name with " > " and matches
|
|
+ // testNamePattern against that; a space-joined name matched nothing under
|
|
+ // a describe block, so every such test was skipped in mutant runs. The
|
|
+ // file task ends the chain and is not part of the name.
|
|
const nameParts = [name];
|
|
let currentSuite = suite;
|
|
- while (currentSuite) {
|
|
+ while (currentSuite && currentSuite.file !== currentSuite) {
|
|
nameParts.unshift(currentSuite.name);
|
|
currentSuite = currentSuite.suite;
|
|
}
|
|
- return nameParts.join(' ').trim();
|
|
+ return nameParts.filter(Boolean).join(' > ').trim();
|
|
}
|
|
function toRawTestId(test) {
|
|
return `${test.file?.filepath ?? 'unknown.js'}#${collectTestName(test)}`;
|
|
diff --git a/dist/src/test-helpers.js b/dist/src/test-helpers.js
|
|
index 56cc786f30c524ae18ce87eef1a67fdf26b703c5..1ad0552d5764d6b8c1ff2215e2e6fb49d7f6bc83 100644
|
|
--- a/dist/src/test-helpers.js
|
|
+++ b/dist/src/test-helpers.js
|
|
@@ -2,13 +2,17 @@
|
|
// This file is used from the testing environment (via stryker-setup.js) and thus could be loaded into the browser (when using vitest with browser mode).
|
|
// Thus we should avoid unnecessary dependencies in this file.
|
|
export function collectTestName({ name, suite, }) {
|
|
+ // Vitest 5 joins a test's full name with " > " and matches
|
|
+ // testNamePattern against that; a space-joined name matched nothing under
|
|
+ // a describe block, so every such test was skipped in mutant runs. The
|
|
+ // file task ends the chain and is not part of the name.
|
|
const nameParts = [name];
|
|
let currentSuite = suite;
|
|
- while (currentSuite) {
|
|
+ while (currentSuite && currentSuite.file !== currentSuite) {
|
|
nameParts.unshift(currentSuite.name);
|
|
currentSuite = currentSuite.suite;
|
|
}
|
|
- return nameParts.join(' ').trim();
|
|
+ return nameParts.filter(Boolean).join(' > ').trim();
|
|
}
|
|
export function toRawTestId(test) {
|
|
return `${test.file?.filepath ?? 'unknown.js'}#${collectTestName(test)}`;
|