From 4143ab8676eeb33fda9e2c6cbbdcdd1b284c5ea4 Mon Sep 17 00:00:00 2001 From: Pengboi Date: Sun, 26 Jul 2026 19:34:15 +0100 Subject: [PATCH] Tests: Stryker mutation testing on the MCP handlers MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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/. --- .gitignore | 5 +++++ mcp/.stryker.conf.json | 29 +++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 mcp/.stryker.conf.json diff --git a/.gitignore b/.gitignore index 12881fa..ff8dc43 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,8 @@ frontend/dist/ node_modules/ *.log .DS_Store + +# Mutation-testing artifacts (mcp/) — reports/ is the HTML output, .stryker-tmp/ holds the +# backing copy used by `inPlace` mode during a run. Both regenerated on every `stryker run`. +mcp/reports/ +mcp/.stryker-tmp/ diff --git a/mcp/.stryker.conf.json b/mcp/.stryker.conf.json new file mode 100644 index 0000000..a564d45 --- /dev/null +++ b/mcp/.stryker.conf.json @@ -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 +}