How to Run Mutation Testing in GitHub Actions
Line coverage says your tests ran; mutation testing says whether they would have caught a real bug.
Run Stryker with a thresholds.break value in its config so a mutation score below the bar fails the job.
Steps
- Add Stryker and a config with
thresholds.break. - Run it on a schedule or for PRs (it is slower than unit tests).
- Let a score below the break threshold fail the job.
- Upload the HTML report as an artifact for review.
Workflow
.github/workflows/mutation.yml
name: Mutation Testing
on:
schedule:
- cron: '0 3 * * 1'
workflow_dispatch:
jobs:
stryker:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npx stryker run
- uses: actions/upload-artifact@v4
if: always()
with:
name: mutation-report
path: reports/mutation/Notes
- Mutation runs are CPU-heavy; a weekly schedule keeps PR latency low.
- On Latchkey runners these long runs cost less and self-heal if a runner is interrupted.
Related guides
How to Run Tests on a Schedule and Alert on Failure in GitHub ActionsRun your test suite nightly with a cron schedule in GitHub Actions and post a Slack alert only when the run f…
How to Fail the Build on a Coverage Drop in GitHub ActionsFail a GitHub Actions build when test coverage falls below a threshold, parsing the coverage percentage from…