# Mutation-Verified Test Generator (Jest, Vitest, pytest)

> Writes tests for your code, then proves they catch bugs with a mutation check, and strengthens them until they do.

Mutation-Verified Test Generator (Jest, Vitest, pytest) is a paid AI agent skill on Agensi by Vethishan, in Testing & Debugging. It loads into your AI agent through the Agensi MCP server, always in its latest approved version.

- Price: $12 (one-time purchase)
- Creator: [Vethishan](https://www.agensi.io/creators/vethishan)
- Category: [Testing & Debugging](https://www.agensi.io/skills/testing-debugging)
- Version: 1.0
- Last updated: 2026-10-19
- Security: scan passed (2026-10-19); every new listing is also reviewed by a person
- Listing: https://www.agensi.io/skills/mutation-verified-test-generator-jest-vitest-pytest
- Tags: testing, code-review, mutation-testing, test-generation, unit-testing, jest, vitest, pytest

## About this skill

### The problem

Generated tests usually pass. That's the problem: a test that passes on correct code tells you nothing until you know it would *fail* on broken code. A suite can execute every line and still miss an off-by-one in a discount tier, an inverted cap, or a deleted validation call. Line coverage can't see that. Mutation testing can.

### What this skill does differently

It doesn't just claim the tests are good: it **measures** it. After writing tests, the agent runs a mutation check. It makes small, realistic bugs in your source file one at a time (`<` → `<=`, `+` → `-`, `&&` → `||`, `true` → `false`, a return value blanked, a call removed), runs your tests after each, and counts how many were caught. Survivors point at exact gaps. The agent adds or tightens tests for them, re-runs the check, and explains any survivor that genuinely can't be caught.

**Tests are written before the mutation check runs.** When the agent scores your existing tests, it sees only the score, not the list of planted bugs. The first-draft score therefore measures tests written from the code's behaviour, not tests tailored to known mutants.

### Who it's for

Developers and teams who want tests they can trust, especially for logic where boundaries matter: pricing, billing, permissions, validation, parsing, date and limit handling. Also useful for checking whether an existing suite would actually catch a regression in a file before you refactor it.

### What the agent does, step by step

1. Detects your language, test framework, test layout, naming, assertion and mocking style, and the narrowest command that runs the relevant tests.
2. Checks there's a restore point: a clean `git status` for the target, or the bundled script's own backup.
3. Reads the target and plans the tests: happy paths, boundaries, edge cases, error paths, and what will be faked and why.
4. If tests already exist, scores them first (score only).
5. Writes tests in your project's style and makes them pass on the unmodified code. If a test reveals a likely bug in the source, it reports it and doesn't change your source.
6. Runs the mutation check, strengthens tests against survivors (up to two rounds), and re-runs.
7. Verifies your source file is restored byte-for-byte, then runs your full test suite once.
8. Reports: tests added and what each covers, the score for each run, every surviving mutant with an explanation, and how the restore was verified.

### Example output

From a pytest project (an invoicing module with late fees, a grace period, a fee cap and discount tiers):

```text
| Run                 | Tests | Mutation score |
|---------------------|-------|----------------|
| Existing tests only |   1   | 45% (9/20)     |
| First draft         |  52   | 90% (18/20)    |
| All 29 mutants      |  52   | 93% (27/29)    |

Survivors (both explained as equivalent, so no test can catch them):
  days_late <= GRACE_DAYS → <   (at exactly day 5 the fee is 0.00 either way)
  rate > MAX_LATE_FEE_RATE → >= (capping 25% to 25% changes nothing)

Restore check:
  OK  billing/invoice.py  sha256 and modification time match original

Bug found (source not changed):
  parse_amount("NaN") raises decimal.InvalidOperation instead of ValueError
```

**These are examples, not promises.** In testing, scores rose from 25% to 95% (TypeScript + Vitest), 50% to 100% (JavaScript + Jest) and 45% to 90% (Python + pytest) on small sample projects. On a real open-source TypeScript CLI tested with node:test, two files with decent existing tests went from about 82% to 100% each. Your results depend on your code and your existing tests.

### How long it takes

**Plan on a few minutes per file.** The skill works on **one source file per run** by default. Each run of the check takes roughly *(your test command's run time) × (number of mutants, 20 by default)*, so keep the test command narrow (the skill does this for you). If you name several files, the agent finishes and reports one before starting the next.

### Safety, and what runs on your machine

- The bundled `scripts/mutate.py` (Python 3.8+, standard library only) **runs your project's own test command as a subprocess**: once on unmodified code, then once per mutant. It runs without a shell, with a timeout.
- It only ever writes to the target file (one mutant at a time, restored after every run, even if a run errors or is interrupted) and to its own backup folder in your system temp directory.
- It verifies the restore by SHA-256 and modification time. If the process is killed outright, the next run refuses to start until you restore from the backup with one command.
- It never overwrites an edit it didn't make.
- **The script makes no network calls, reads no environment variables and installs nothing.** The agent asks before installing anything and uses `npx --no` so missing tools fail instead of downloading.
- If Stryker or mutmut is already installed, the agent offers to use it instead, scoped to the target file.
- No Python? The agent applies the same mutation operators by hand with its own edit tool, under the same safety rules.

### Supported

| | |
|---|---|
| **Fully supported (tested)**

## Requires

- Jest or Vitest or pytest
- Node.js
- tsx
- mocha
- stryker
- Optional: Python 3.8+
- Optional: Git

Without Python the agent applies mutations by hand; without Git the skill makes a backup first.

## Known limitations

One target file per run is recommended (usually a few minutes). Regex patterns and string constants aren't mutated, and some surviving mutants are equivalent (no test could catch them); the report explains each one. Fully tested with Jest, Vitest and pytest; node:test, Mocha and unittest are best-effort. Mutation scores depend on your code, so the demo results are examples, not guarantees. Works best with strong tool-calling models.

## How to use this skill

1. Connect your AI agent to Agensi once: add the MCP server https://mcp.agensi.io/mcp/auth and sign in with your Agensi account (OAuth, no API key). Steps for Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and other agents: https://www.agensi.io/docs/mcp-setup
2. Ask your agent: "Use the Mutation-Verified Test Generator (Jest, Vitest, pytest) skill from Agensi" and describe your task.
3. Buy it on the listing or let your agent ask you first; your agent then loads it from Agensi when it needs it. Every paid skill has a money-back guarantee: https://www.agensi.io/docs/money-back-guarantee

## Frequently asked questions

### What is a mutation check?

It makes small deliberate bugs in your code, one at a time (for example > → >=, or true → false), and runs your tests against each one. If a test fails, the bug was caught. The percentage caught is your mutation score, a much better measure of test quality than coverage.

### Will it change my source code?

Only temporarily, during the mutation check. Before mutating, it confirms git is clean or makes a backup, applies one mutant at a time, and always restores the original, even if a run is interrupted. At the end it checks that every file is byte-for-byte identical to the original. The only lasting change is your new test file.

### What do I need installed?

Your project’s test runner (Jest, Vitest or pytest). Python 3.8+ is recommended for the bundled mutation script, which uses the standard library only. Without Python, the agent applies the same mutations by hand. Git is recommended.

### Which frameworks and agents does it work with?

Fully tested with Jest, Vitest and pytest, and also used successfully with node:test on a real project. Tested in Claude Code and Agent Harness, and built on the open SKILL.md standard for other compatible agents.

### How long does it take?

Usually a few minutes per file, about 15–20 agent turns. One target file per run is recommended, especially in agents with turn limits

---

Source: [Agensi](https://www.agensi.io), the marketplace of skills for AI agents. Any MCP-compatible agent (Claude, ChatGPT, Claude Code, Codex, Cursor, VS Code and more) connects at https://mcp.agensi.io/mcp/auth and signs in with an Agensi account; setup for every agent: https://www.agensi.io/docs/mcp-setup. Append .md to any skill, guide or docs address on agensi.io for its markdown version.
