Mutation testing for JavaScript and TypeScript

Find the tests that test nothing.

Mootant changes your code in hundreds of small ways and runs the tests that should notice. The mutants that survive are the gaps in your suite, and the agent skill in the box knows how to close them.

$ npm install -D mootant
● mootant run src                                 vitest 5.0.4

dry run         11 tests in 0.2s
mutants         26 in 3 files
time            1.5s (start 0.1s, dry run 0.2s, isolated 1.2s)

killed          25
survived        1
timeout         0
no coverage     0
score           96.15%

survived 1

src/discount.ts
  2:7  comparison-operator  q31p
    - if (total >= 100 || isMember) {
    + if (total > 100 || isMember) {
    test: test/discount.test.ts

re-check one: mootant run src --mutant q31p

Coverage lies

Coverage shows which lines ran. It can't tell whether any test would notice them change.

Code coverage vitest run --coverage
100% Every statement, branch and line ran.
File StmtsBranchLines
cart.ts 100%100%100%
discount.ts 100%100%100%
shipping.ts 100%100%100%
Mutation testing mootant run src
1 survived of 26 mutants · score 96.15%
src/discount.ts:2:7
- if (total >= 100 || isMember) {
+ if (total > 100 || isMember) {
No test checks an order of exactly 100, so all 11 tests still pass.

Why Mootant

Mutation testing is often slow, noisy, and hard to act on. Mootant was built to fix all three.

  • Less noise

    Mootant skips duplicate, likely equivalent, and likely hanging mutants, so you spend less time investigating false alarms.

  • Finds hidden gaps

    Mootant mutates numbers, return values, and awaits-not just operators-to expose tests that miss changes in behavior.

  • Fast reruns

    Mootant caches results and tracks their dependencies. Mutants unaffected by your changes don't need to run again.

  • Ready for CI

    Test only the lines changed in a pull request, and fail CI when the mutation score falls below your threshold.

  • Actionable reports

    Every survivor shows the code change and a suggested test file to improve. Uncovered mutants are reported separately.

  • Fits your stack

    Use your existing Vitest, Jest or Node Test setup. JavaScript and TypeScript work with all three, Vue and Svelte with Vitest.

How it works

  1. 01 · Instrument

    Built once, switched at runtime

    Mootant picks the changes worth testing and compiles them all into your code in memory, each behind a switch. Your files stay untouched.

  2. 02 · Run

    Each mutant on its own

    A dry run maps which test files reach which mutant. Then every mutant runs alone, on a fresh module graph, with only those files, until a test fails.

  3. 03 · Fix

    Survivors become tests

    Each survivor comes with a diff, the test file to extend and a command to re-check it. Fix it yourself or hand it to the agent skill.

Ships with an agent skill

Mutation testing produces a to-do list that nobody wants to work through by hand.

The skill reads the report, writes the missing tests and asks Mootant to confirm each kill. You review the new tests.

$ npx skills add azat-io/mootant
> fix the surviving mutants in src

$ mootant run src --json
{ …, "mutants": [{ …, "file": "src/discount.ts", "line": 2,
    "after": ["  if (total > 100 || isMember) {"],
    "testFiles": { "test/discount.test.ts": 3, … },
    "recheck": "mootant run src --mutant q31p780qv6yk" }] }

test/discount.test.ts
+ test('orders of exactly 100 get 10% off', () => {
+   expect(getDiscount(100, false)).toBe(10)
+ })

$ mootant run src --mutant q31p780qv6yk
killed          1
survived        0
score           100%

Works with your stack

File extensions

  • .js
  • .mjs
  • .cjs
  • .jsx
  • .ts
  • .mts
  • .cts
  • .tsx
  • .vue
  • .svelte

Test runners

  • Vitest

    ^5.0.0

  • Jest

    ^29.7.0 || ^30.0.0

  • Node Test

    ^20.19.0 || >=22.12.0

See what survives

The report of a small sample shop: scores, every mutant in its code and what each test reaches.

Add --html to a run to write the same report for your project.

View Demo