Command Palette

Search for a command to run...

UnylyUnyly
Назад к скиллам

stryker-js

БесплатноБез исполняемых скриптовНе проверен

StrykerJS is a mutation testing tool for JavaScript and TypeScript: it makes small deliberate changes to your source code and checks whether your tests fail…

TerminalSkillsот TerminalSkills★ 221 звезда на GitHub

Об этом скилле

StrykerJS — mutation testing for JavaScript and TypeScript

Overview

Line coverage tells you which code your tests execute, not whether they would notice a bug. StrykerJS answers the second question. It copies your project into a sandbox, applies one small change at a time (a >= becomes >, a && becomes ||, a condition becomes true), and reruns the tests for each change. A change that makes a test fail is "killed". A change that no test notices "survived", and every survivor points at a missing or weak assertion.

The result is a mutation score: killed mutants divided by all mutants that were tested. Stryker can fail the build under a chosen score, write an HTML report, and reuse earlier results so reruns only test what changed.

Use it on code whose behaviour matters (pricing, permissions, parsing, validation). Do not point it at a project whose tests are already failing: the initial run must pass.

Instructions

Installation and setup

StrykerJS 10 needs Node.js 22 or newer. Install the core package plus a runner for your test framework as dev dependencies:

npm install --save-dev @stryker-mutator/core
npm install --save-dev @stryker-mutator/vitest-runner   # Vitest
# or: @stryker-mutator/jest-runner, @stryker-mutator/mocha-runner,
#     @stryker-mutator/karma-runner, @stryker-mutator/tap-runner,
#     @stryker-mutator/cucumber-runner
npm install --save-dev @stryker-mutator/typescript-checker   # TypeScript projects only

The runner package must be the same version as @stryker-mutator/core. The guided way is npm init stryker, which asks about your framework and writes a config file. It is interactive, so in an agent session write the config by hand instead (below).

If the framework has no dedicated runner (for example node --test), use the built-in command runner. It runs any shell command and treats a non-zero exit code as a killed mutant.

Configuration file

Create stryker.config.json (a .mjs file exporting a default object works too). A minimal, verified setup for a project that uses the command runner:

{
  "$schema": "./node_modules/@stryker-mutator/core/schema/stryker-schema.json",
  "testRunner": "command",
  "commandRunner": { "command": "npm test" },
  "mutate": ["src/**/*.js"],
  "coverageAnalysis": "off",
  "reporters": ["clear-text", "html", "json"],
  "thresholds": { "high": 80, "low": 60, "break": 50 }
}

For Vitest or Jest, set "testRunner": "vitest" (or "jest") instead and drop commandRunner and coverageAnalysis. Those runners report coverage, so the default perTest strategy works and runs only the tests that touch each mutant, which is much faster.

Key options:

  • mutate: globs of production files to mutate. Prefix with ! to exclude, for example ["src/**/*.ts", "!src/**/*.spec.ts"]. A line range such as "src/price.js:1-11" limits mutation to a part of a file. Never list test files. The default is every JS-like file under src or lib except tests.
  • thresholds: high (default 80), low (default 60) and break. A score below break makes stryker run exit with code 1. The default break is null, so the build never fails.
  • coverageAnalysis: perTest (default), all or off. The command runner cannot provide coverage, so use off with it.
  • reporters: clear-text (console), progress, html, json, dashboard, dots. The HTML report goes to reports/mutation/mutation.html.
  • concurrency: number of worker processes, default is the number of logical CPUs minus one (all of them on 4 or fewer). Lower it on a small CI runner.
  • checkers: ["typescript"] discards mutants that do not compile, which removes noise in TypeScript code.

Running

npx stryker run                      # uses stryker.config.json
npx stryker run --mutate "src/price.js"   # one file while iterating
npx stryker run --dryRunOnly         # only checks that the initial test run passes

Run --dryRunOnly first on an unfamiliar project: it confirms the sandbox and the test command work before spending time on mutants.

Reading the clear-text report

Each survivor is printed with its mutator name, location, and the change:

[Survived] EqualityOperator
src/price.js:3:7
-     if (total >= 100) return total * 0.9;
+     if (total > 100) return total * 0.9;

This says no test calls the function with exactly 100. Statuses you will see: Killed, Survived, NoCoverage (no test executes that line), Timeout (counted as detected), CompileError (type checker rejected it), Ignored. Fix survivors by adding an assertion that fails for the mutated behaviour, then rerun.

Ignoring equivalent mutants

Some mutants cannot be killed because the changed code behaves the same (for example a < b ? b : a changed to a <= b ? b : a). Disable them with a comment, giving a reason that appears in the report:

// Stryker disable next-line EqualityOperator: <= gives the same result for equal values
Полный SKILL.md на GitHub

Установить stryker-js в Claude Code и Claude Desktop

Зарегайся, чтобы установить скилл

Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.

  • Открой команду установки в одну строку
  • Сохраняй скиллы в синхронизируемую библиотеку
  • Уведомления, когда скиллы обновляются
Зарегаться бесплатноУ меня уже есть аккаунт

Разрешённые инструменты

Инструменты, которые скиллу разрешено вызывать.

Без ограничений — скилл может использовать любой инструмент.

Вложенные файлы

_scores.json

FAQ

Что делает скилл stryker-js?

StrykerJS is a mutation testing tool for JavaScript and TypeScript: it makes small deliberate changes to your source code and checks whether your tests fail, which shows how well the tests really protect the code. Use it when asked to "run mutation testing", "check test quality", "find weak tests", "improve the mutation score", "set up Stryker", or to gate a CI build on a mutation score.

Как установить скилл stryker-js?

Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.

Скилл stryker-js запускает скрипты?

Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.

Похожие скиллы

Сравнить stryker-js с