Tests: Stryker mutation testing on the MCP handlers

Adds Stryker 9.6.1 as a devDep and a .stryker.conf.json scoped to the three MCP-only
modules (src/state.js, src/labels.js, src/tools.js). The reused pure lib in
frontend/src/lib/ is deliberately excluded — it has its own 92-test vitest suite, and
mutating it here would just re-test it under a different label.

Two non-obvious config choices, both learned the hard way:
 · inPlace: true. Stryker's default copies the project to a sandbox, but the MCP test
   file imports "../../frontend/src/lib/*.js" — a relative path that breaks the moment
   the source is moved. inPlace mutates files where they live, keeps a backup in
   .stryker-tmp/backup-*/ during the run, and restores on exit. Verified: after the
   run, `git diff` shows no changes and all 92+32 tests still pass.
 · vitest.related: false. The vitest runner's related-files mode uses static import
   analysis to pick which tests to run per mutant; it can't see the cross-directory
   imports and reported "no tests were found". Disabling it means every mutant runs
   the full suite — slower (~54s for 847 mutants) but accurate.

Baseline first run: 39.32% mutation score (333 killed, 330 survived, 184 no-coverage).
Most of the survivors are zod schema string literals (the unit suite bypasses the SDK's
validation by calling handlers directly), and the bulk of the no-coverage debt lives in
state.js — file watching, multi-user resolution and the mtime fallback paths. The HTML
report at mcp/reports/mutation/mutation.html (gitignored, regenerated per run) shows
each survived mutant inline.

Run with `npm run mutation:test` from mcp/.
This commit is contained in:
Pengboi committed 2026-07-26 19:34:15 +01:00
1 parent 92914dea43
commit 4143ab8676
2 files changed
+34

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
{
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"packageManager": "npm",
"testRunner": "vitest",
"vitest": {
"configFile": "vitest.config.js",
"related": false
},
"coverageAnalysis": "perTest",
"mutate": [
"src/state.js",
"src/labels.js",
"src/tools.js"
],
"testFiles": [
"test/**/*.test.js"
],
"inPlace": true,
"ignorePatterns": [],
"thresholds": {
"high": 80,
"low": 60,
"break": 0
},
"reporters": ["html", "progress", "clear-text"],
"concurrency": 2,
"disableTypeChecks": true,
"cleanTempDir": true
}