Skip to content
Latchkey

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

Run this faster and cheaper on Latchkey managed runners. Start free →