stryker-mutation
БесплатноБез исполняемых скриптовНе проверенUse when a JavaScript or TypeScript suite has high coverage but bugs still slip through, and the team wants mutation testing to find weak tests. Sets up…
от testland★ 18 звёзд на GitHubОб этом скилле
stryker-mutation
Overview
Mutation testing plants small bugs (mutants) in production code and re-runs the tests. A mutant that survives means no test noticed the change: the line is covered but not checked. StrykerJS does this for JavaScript and TypeScript, including React, Angular, Vue, Svelte and Node projects ([introduction][si]).
When to use
- A JS/TS suite has ≥80% line or branch coverage and the team wants to know whether its assertions catch bugs.
- Reviews keep finding weak assertions (
toBeTruthy()on objects); the mutation score makes the cost visible. - A critical module needs a stronger bar than coverage.
Step 1 - Install the core and one runner
npm install --save-dev @stryker-mutator/core @stryker-mutator/jest-runner
# or: mocha-runner, vitest-runner, karma-runner, jasmine-runner, cucumber-runner, tap-runner
Step 2 - Write the config
npx stryker init asks a few questions and writes the config. The
result should look like this:
{
"$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
"testRunner": "jest",
"coverageAnalysis": "perTest",
"mutate": ["src/**/*.ts", "!src/**/*.test.ts", "!src/**/*.d.ts"],
"reporters": ["progress", "clear-text", "html"],
"thresholds": { "high": 80, "low": 60, "break": 50 }
}
| Field | Meaning ([configuration][cfg]) |
|---|---|
mutate |
Globs of files to mutate. Exclude test files and type declarations. Exclude generated files one by one, on evidence (generator banner, codegen manifest), not by directory name. |
coverageAnalysis |
perTest (the default since v5) runs only the tests that cover each mutant. |
thresholds |
high / low colour the report; break makes stryker run exit with code 1 when the score is below it. break defaults to null (never fail). All three values must be given together. |
concurrency |
Worker processes; defaults to n-1 logical cores (n when there are 4 or fewer). |
checkers |
["typescript"] type-checks each mutant first, so type-invalid mutants are not run. |
Step 3 - Check the setup before the full run
A full run can take 5-30 minutes, so validate cheaply first:
npx stryker run --dryRunOnlyruns only the initial test run ([configuration][cfg]). It must pass; a failing dry run means the runner or config is wrong, not the tests.- Run on one small file:
npx stryker run --mutate src/cart.ts. Check the mutant count is plausible and the HTML report opens (reports/mutation.htmlby default). - Only then run
npx stryker runon the fullmutateset.
Step 4 - Read the result
[Survived] EqualityOperator
src/cart.ts:42:5
- if (item.qty < 0) throw new Error("bad qty");
+ if (item.qty <= 0) throw new Error("bad qty");
A survived mutant is a missing test: here nothing checks qty = 0.
Add that test, re-run the file with --mutate src/cart.ts, and confirm
the mutant is now Killed.
The summary gives killed, survived, timed-out and no-coverage counts and the mutation score. Some survivors are equivalent mutants (behaviour unchanged); record them and move on.
Judgement rules when the score looks wrong
- No-coverage mutants in a module that has tests: check the runner's test-file globs and the dry-run test count before writing tests or excluding the file. A suite the runner never loads looks exactly like missing tests.
- Generated code: exclude the files a generator actually writes
(banner or codegen manifest). Hand-written code that lives next to
them stays in
mutate, and generated code gets no test suite of its own. - A sudden score jump with no new tests: look for test files or
whole modules newly dropped from
mutate; restate the score on the agreed scope. - A failing gate: fix what is measured or the tests, never lower
breakto make it pass. Check the CI step does not swallow the exit code (|| true,continue-on-error). - Slow PR runs: use a native runner (not the
commandrunner, which cannot doperTestanalysis) and incremental mode before narrowing the scope.
Step 5 - Set the break threshold with the team
Set break a few points below today's score, agree it in a PR, and
raise it as the score improves. A break far above the current score
fails every build and gets switched off.
Step 6 - Incremental mode for PRs
npx stryker run --incremental (or "incremental": true) stores
results in reports/stryker-incremental.json and on the next run
re-tests only mutants whose code or covering tests changed
([incremental][inc]). Keep that file between CI runs (cache it, or
download the last main-branch report). Stryker only tracks mutated and
test files, so changes to dependencies, environment variables or
snapshot files are not detected; run a full --force run on a
schedule to catch them.
on:
pull_request:
schedule:
- cron: "0 2 * * 0" # weekly full run
jobs:
mutation:
runs-on: ubunt
Установить stryker-mutation в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
Вложенные файлы
FAQ
Что делает скилл stryker-mutation?
Use when a JavaScript or TypeScript suite has high coverage but bugs still slip through, and the team wants mutation testing to find weak tests. Sets up StrykerJS: the Jest, Vitest, Mocha or Karma runner, stryker.conf.json, thresholds and incremental runs on pull requests.
Как установить скилл stryker-mutation?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл stryker-mutation запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic