CLI reference
Use mootant run to check your tests or mootant list to inspect mutants
without running them. Command line options override the
configuration.
npx mootant run srcPass files or directories, relative to the current directory. Without paths,
run uses run.paths. Mootant detects the test
runner and uses its existing configuration; see
compatibility for supported runners and frameworks.
Mootant selects test files related to every file it can mutate in the paths,
even with --mutant or --since, and they must pass without mutants first. It
then reports surviving mutants, uncovered mutants and errors in separate
sections, grouped by file. Each finding shows the source lines before and after
the change and a short id, then the reason of an error or, when Mootant finds
one, a test file to extend.
In a terminal, the report also lists the five files with the lowest scores below
100%. Piped output and JSON leave this list out. Test output is hidden unless
you use --verbose or the tests fail without mutants. Snapshots are never
written.
| Option | What it does |
|---|---|
--threshold <score> | Sets the lowest mutation score, from 0 to 100, that passes. No threshold by default. |
--concurrency <n> | Limits how many test files run at once. Defaults to Vitest’s or Jest’s maxWorkers, or CPU cores minus one for Node Test. |
--mutant <id> | Runs only this mutant. Accepts a full id or a unique prefix of at least four characters. Repeat the option for more mutants. |
--no-cache | Runs every selected mutant again instead of reusing earlier verdicts, and saves no new ones. --cache enables caching. |
--incremental | Reuses a cached verdict while the code of its mutant and its tests stay the same, even after changes elsewhere. A verdict may be stale. Requires caching; --no-incremental disables it. |
--fast | Tries many mutants in one test run. A kill may be false, and concurrent tests run one at a time. Applies to Vitest; it changes nothing with Jest and Node Test. --no-fast disables it. |
--parallel-units | Runs a test file for several mutants at once. A verdict may be false if the tests use a fixed file, port or database. Applies to Vitest and Node Test; it changes nothing with Jest. --no-parallel-units disables it. |
--html | Writes an HTML report to .mootant/report.html in the project root, or to the path set by run.html. --no-html skips it for this run. |
--verbose | Shows test output, the covering test of each survivor and the runs of the test runner. With --json, prints the full report with offsets, original and replacement texts, covering tests and timings. |
--all | Lists every mutant, including killed, timed-out and ignored mutants. Requires --json. |
The run settings describe caching,
incremental runs, fast mode, parallel units and timeouts in detail. A re-check
with --mutant writes no HTML report unless you also pass --html, so it keeps
the report of the whole run.
The mutation score is the percentage of scored mutants that were killed or timed
out. Surviving and uncovered mutants count against the score; Ignored and
Error are excluded from it. The report also shows a covered score, which
leaves out uncovered mutants; the threshold applies to the full score.
The exit code is 1 when a run has errors or its score falls below the threshold. Surviving or uncovered mutants alone do not fail a run without a threshold. Without mutants to score, any threshold passes. When something keeps the process running after the report, such as a server a Vitest global setup leaves open, Mootant ends it at least 10 seconds later with a warning and the exit code of the run.
A run that gets SIGINT (Ctrl+C), SIGTERM or SIGHUP stops its test processes, removes its temporary files and ends by the same signal without a report, so a shell shows exit code 130, 143 or 129. Later signals wait for this cleanup, which gets 5 seconds: past them, as when a global setup or teardown hangs, Mootant removes its own files and ends anyway, and those of the test runner may stay. With Vitest, processes the tests start stay when only Mootant gets the signal, and project code that handles the signal itself, such as a server a global setup starts, may end the run before its cleanup.
npx mootant list srclist requires at least one file or directory. It shows the mutants of these
files without running the tests. run leaves out test and setup files. Use
ignore comments to keep selected mutants, regions or
files out of runs and the score; list marks them as ignored.
| Option | What it does |
|---|---|
--skipped | Also lists the changes Mootant considered and skipped, with their category, rule and reason. |
--verbose | With --json, prints offsets, kinds, original and replacement texts and mutator descriptions. Requires --json. |
See skipped changes for the categories and the limits of heuristic rules. Code that is never mutated, such as types, decorators and enums, does not appear in the skipped list.
These options work with both run and list:
| Option | What it does |
|---|---|
--config <path> | Uses this configuration file instead of the one Mootant finds. See configuration file. |
--preset <name> | Selects recommended, strict or a plugin preset, replacing the configuration’s presets. recommended is the default; strict adds noisier mutants. |
--since <ref> | Selects mutants on lines changed since the merge base of <ref> and HEAD, including uncommitted changes and untracked files. |
--json | Prints the report as JSON for scripts and agents. See JSON output. |
--no-color | Disables colors. NO_COLOR=1 does the same; --color turns colors on unless NO_COLOR is set. |
-h, --help | Prints the command line help. |
-v, --version | Prints the version. |
For example, to check the lines a pull request changed and require a score of at least 80:
npx mootant run src --since origin/main --threshold 80--since also includes mutants on unchanged lines when Mootant uses them in
place of a skipped change on a changed line.
The comparison ref must exist in the local Git repository. In CI, fetch the base
branch and enough history to find its merge base with HEAD.
npx mootant run src --jsonThe default JSON report lists surviving mutants, uncovered mutants and errors.
Add --all to include every mutant, and --verbose for the full details:
npx mootant run src --json --verbose --allmootant list src --json lists mutants without running tests. Add --skipped
to include the changes Mootant left out.
Progress goes to stderr. A run that stops early, such as on failing tests, prints its error to stderr and no JSON.
See the JSON report for examples, fields, statuses and the schema version.