Validate test effectiveness with mutation testing using Stryker (TypeScript/JavaScript with Vitest or bun test via @hughescr/stryker-bun-runner) and mutmut (Python). Find weak tests that pass despite code mutations. Use to improve test quality.
Installs just this skill. Get the whole plugin for auto-invocation.
โก How it fires
How this skill gets triggered: by you, by Claude, or both.
Fires itselfClaude auto-loads it when your prompt matches the work.
You can call itInvoke it directly when you want it.
Slash command/mutation-testing
๐๏ธ Context preview
The summary Claude sees to decide when to auto-load this skill.
Validate test effectiveness with mutation testing using Stryker (TypeScript/JavaScript with Vitest or bun test via @hughescr/stryker-bun-runner) and mutmut (Python). Find weak tests that pass despite code mutations. Use to improve test quality.
๐ Stats
Stars194
Forks29
LanguageTypeScript
LicenseMIT
๐ฆ Ships with claude-skills
</> SKILL.md
mutation-testing.SKILL.md
---name: mutation-testing
description: Validate test effectiveness with mutation testing using Stryker (TypeScript/JavaScript with Vitest or bun test via @hughescr/stryker-bun-runner) and mutmut (Python). Find weak tests that pass despite code mutations. Use to improve test quality.
allowed-tools: Bash, Read, Edit, Write, Grep, Glob, TodoWrite
license: MIT
---# Mutation Testing
Expert knowledge for mutation testing - validating that your tests actually catch bugs by introducing deliberate code mutations.
## Core Concept
- **Mutants**: Small code changes introduced automatically
- **Killed**: Test fails with mutation (good - test caught the bug)
- **Survived**: Test passes with mutation (bad - weak test)
- **Score**: Percentage of mutants killed (aim for 80%+)
## TypeScript/JavaScript (Stryker)
### Vitest Runner
#### Installation
```bash
# Using Bun
bun add -d @stryker-mutator/core @stryker-mutator/vitest-runner
# Using npm
npm install -D @stryker-mutator/core @stryker-mutator/vitest-runner
```
#### Configuration
```typescript
// stryker.config.mjs
// bunPath: '/path/to/bun', // only if custom Bun install
// timeout: 30000, // test timeout (ms)
// env: { DEBUG: 'true' },
// bunArgs: ['--bail'],
},
}
```
#### Key Behaviors
- **Sequential execution**: Runs tests with `--concurrency=1` for accurate per-test coverage. Slower than parallel but required for correct test-to-mutant correlation.
- **Concurrent test patching**: Automatically patches `describe.concurrent()`, `test.concurrent()`, `it.concurrent()` to run sequentially during mutation testing โ no code changes needed.
- **Inspector Protocol**: Uses Bun's WebSocket Inspector API to discover tests and correlate coverage.
### Running Stryker
```bash
# Run mutation testing
bunx stryker run
# Incremental mode (only changed files)
bunx stryker run --incremental
# Specific files
bunx stryker run --mutate "src/utils/**/*.ts"
# Open HTML report
open reports/mutation/html/index.html
```
### Example: Weak Test
```typescript
// Source code
function calculateDiscount(price: number, percentage: number): number {
return price - (price * percentage / 100)
}
// โ WEAK: Test passes even if we mutate calculation
test('applies discount', () => {
expect(calculateDiscount(100, 10)).toBeDefined() // Too weak!