test: add StrykerJS mutation testing foundation - #847
Conversation
Sets up mutation testing to measure how effectively the test suite catches bugs, scoped to util/ as the initial baseline (issue lnp2pBot#760). - Add @stryker-mutator core + mocha-runner + typescript-checker - stryker.config.json: mocha runner, perTest coverage, non-blocking (break: null), mutate util/** - npm scripts: mutation-test, mutation-test:util, build:test - Non-blocking CI workflow (weekly + manual) on node:20-bookworm that uploads the HTML report as an artifact - gitignore Stryker outputs The build:test script (full tsc + test tsc) is used as Stryker's build command so the sandbox build is complete: tsconfig.test.json alone does not compile dynamically required files (e.g. bot/modules/block/commands.ts), which only works in CI because it runs a full tsc beforehand. Baseline on util/: 57.69% mutation score on covered code in util/index.ts (the only tested util file); the rest of util/ has no tests yet. Part of lnp2pBot#760
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
WalkthroughAdds Stryker mutation-testing setup for the ChangesMutation testing setup
Estimated code review effort: 2 (Simple) | ~10 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/mutation-testing.yaml:
- Around line 26-40: The workflow still uses mutable GitHub Action tags in the
mutation-testing job, so update the actions referenced by actions/checkout and
actions/upload-artifact to their full 40-character commit SHAs and keep the
original version as an inline comment for readability. Make this change in the
mutation-testing workflow alongside the existing run steps, preserving the same
behavior while removing tag-based supply-chain risk.
In `@stryker.config.json`:
- Around line 1-19: Stryker is not invoking the installed TypeScript checker
because the configuration lacks the explicit checker activation. Update the
Stryker config to enable the TypeScript checker via the checkers setting in the
existing JSON alongside the current testRunner, mutate, and thresholds options.
Keep the rest of the StrykerJS configuration unchanged so mutation testing still
runs with type checking enabled.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro
Run ID: a33067e2-79d9-478e-940f-d9d29f1cb9c0
⛔ Files ignored due to path filters (1)
package-lock.jsonis excluded by!**/package-lock.json
📒 Files selected for processing (4)
.github/workflows/mutation-testing.yaml.gitignorepackage.jsonstryker.config.json
|
Great work! Please address CodeRabbit's comments before merging. |
- Pin GitHub Actions to full commit SHAs (actions/checkout, upload-artifact) with the version tag kept as an inline comment, removing tag-based supply-chain risk. - Enable the StrykerJS TypeScript checker (checkers + tsconfigFile) so type-invalid mutants are rejected before running tests. The @stryker-mutator/typescript-checker plugin was already a devDependency.
|
Thanks @Matobi98! Both CodeRabbit points are addressed in
|
There was a problem hiding this comment.
Actionable comments posted: 1
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/mutation-testing.yaml:
- Line 26: Update the actions/checkout step in the mutation-testing workflow to
set persist-credentials to false, ensuring checkout does not retain the GitHub
token while leaving the pinned action version and subsequent steps unchanged.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: ddc4b2ab-c03b-4f11-afa5-636ec5c4862e
📒 Files selected for processing (2)
.github/workflows/mutation-testing.yamlstryker.config.json
The mutation-testing job only reads the repo (no push), so the checkout should not retain the GitHub token in git config. Addresses CodeRabbit.
|
Done in |
|
Tip For best results, initiate chat on the files or code changes.
If you found this review helpful, would you consider giving us a shout-out on X? Thank you for using CodeRabbit! You are interacting with an AI system. |
Part of #760. First, foundational PR: set up StrykerJS and establish a baseline on
util/. Writing tests for surviving mutants and raising the threshold will follow as separate focused PRs.What this adds
@stryker-mutator/core+mocha-runner+typescript-checkerstryker.config.json— mocha runner,perTestcoverage, non-blocking (break: null), scoped toutil/**mutation-test,mutation-test:util,build:testworkflow_dispatch) onnode:20-bookwormthat uploads the HTML report as an artifactBaseline on
util/util/index.tsutil/This is exactly the signal mutation testing gives: it shows where a bug could be introduced and slip past the suite.
One integration note
Stryker builds in a clean sandbox, which surfaced that
tsconfig.test.json(includetests/**/*) does not compile dynamicallyrequire()d files such asbot/modules/block/commands.ts— it only works normally because CI runs a fulltscfirst. Rather than touch that code, I use abuild:testscript (fulltsc+ testtsc) as Stryker's build command so the sandbox build is complete.Validation
tsc, lint, prettier cleanutil/Summary by CodeRabbit