mutation-testing

Runs Stryker mutation testing on JavaScript and TypeScript code to find weak or missing tests.

Updated May 18, 2024
One-click install
npx skills add https://github.com/joshhornby/dotfiles --skill mutation-testing-joshhornby
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mutation-testing
Source: https://github.com/joshhornby/dotfiles/tree/main/.claude/skills/mutation-testing
Command: npx skills add https://github.com/joshhornby/dotfiles --skill mutation-testing-joshhornby

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? Code coverage shows which lines your tests execute but not whether they would catch real bugs. This Skill verifies test effectiveness by introducing small mutations into production code and checking whether your test suite kills them, exposing weak assertions, missing boundary tests, and untested edge cases before a PR ships. ## Core Features & Use Cases - Stryker Setup and Configuration: Detects existing Stryker config, recommends exact pinned versions, and generates a starting configuration matched to the project's test runner (Vitest, Jest, Mocha). - Branch-Diff Mutation Runs: Provides a diff-scoped workflow that mutates only files changed against the review base, with clean-working-tree enforcement and monorepo-aware scoping. - Survivor Triage and TDD Killing: Categorizes mutants as killed, survived, no-coverage, or equivalent, then drives a focused loop of writing behavior tests that kill worthwhile survivors. - Use Case: After finishing a feature branch, run the diff-scoped mutation check as a PR-readiness gate, discover that a boundary condition mutant survived, add a boundary test, and re-run the focused check before opening the PR. ## Quick Start Ask the assistant to set up Stryker and run mutation testing on the current branch diff, then strengthen any tests that let mutants survive.

Frequently Asked Questions about mutation-testing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I set up Stryker mutation testing in a TypeScript project?

Run the Stryker initializer with your package manager, such as pnpm dlx create-stryker, using reviewed exact versions. Then configure the test runner plugin for your framework, scope the mutate patterns to first-party source, and exclude tests, fixtures, and generated files.

How do I run mutation testing only on changed files in a branch?

Use a diff-scoped helper that collects changed production files with git diff against the review base and passes them to Stryker's --mutate option. Require a clean working tree first, since staged, unstaged, and untracked changes are excluded from the diff.

What is the difference between code coverage and mutation testing?

Coverage measures which lines your tests execute, while mutation testing measures whether tests detect deliberate bugs introduced into that code. A suite can have full line coverage yet let mutants survive because assertions are weak or missing.

Does Stryker work with Vitest Browser Mode?

Stryker's Vitest runner targets Node-based test projects, not browser-mode ones. For UI packages using Browser Mode, scope mutation to non-UI source covered by Node tests or point Stryker at the Node project in a multi-project setup.

When should I not run mutation testing during TDD?

Do not run the mutation harness inside each RED-GREEN-REFACTOR increment, since its cost grows with the codebase and slows short feedback loops. Use mutator rules mentally during RED, and run the harness once as an end-of-phase PR-readiness gate.

What should I do with surviving mutants that seem equivalent?

Equivalent mutants produce identical observable behavior and cannot be killed by a useful test, so document why behavior cannot differ. If many appear, consider whether the production code can be simplified.