fallow mutation
Find the options, statuses, report fields and exit codes of fallow mutation, which finds the code changes that no test detects.
fallow mutation makes small changes to the code (mutants), runs the project tests against each mutant, and reports the mutants that no test detects.
For the concepts and the workflow, read Mutation testing.
Synopsis
fallow mutation [OPTIONS] [PATH]... [COMMAND]
The command is opt-in. Bare fallow, fallow audit and fallow health do not run it. Only a run without --plan, and inspect --replay, run project code.
Subcommands
| Subcommand | Description |
|---|---|
inspect | Show one mutant of a saved report against the current file. |
tasks | List the open tasks of a saved report as one batch. |
export | Write a saved report in the open mutation-testing-report-schema format. |
test-run | Run the test command so that it records the dry-run facts of this scope (Vitest only) |
Without --report, each subcommand reads the saved report of the last run. Pass the same --root and --config as the run, because the config can move the cache directory. A --plan document has no test results, so tasks and export refuse it with exit code 2.
inspect
fallow mutation inspect [OPTIONS] <MUTANT_ID>
| Argument | Description |
|---|---|
<MUTANT_ID> | The mutant_id from the report |
| Option | Description |
|---|---|
--report <PATH> | A saved fallow mutation --format json report or --plan document (default: the report of the last run) |
--replay | Call the export of the mutated function with --args on the original and on the mutant, three times each, and compare the results. Runs project code. |
--args <JSON> | The arguments of the replay call as a JSON array, for example [2, 3]. Objects with a $replay tag give undefined, special numbers, bigints, dates, regular expressions, maps, sets and typed arrays (default: up to 3 inputs that a fallow mutation --record-args values run recorded for the export) |
--export <NAME> | The export to call (default: the export that holds the mutated function) |
--call-timeout <DURATION> | The time limit of one replay call, for example 30s (default: 5s, at most 10m). A call past it is timed_out |
inspect shows the change of one mutant against the current file, and its covering tests. Without --replay, it runs no code. The report holds no source text, so inspect reads the current file and finds the mutant again by its id and span.
fresh: the file has the SHA-256 digest of the report. The output shows the original line, the changed line, the covering tests and the killing test.stale: the file changed, is missing, or has no digest in the report. The output shows no code. A--plandocument has digests only for the files that it instruments.- No saved report exits with code 2 and
FALLOW_MUTATION_NO_REPORT. An id that is not in the report exits with code 2 andFALLOW_MUTATION_UNKNOWN_MUTANT.
Replay
--replay calls the export that holds the mutated function, with one input, on the current code and on the mutant. It runs the module of the file and its imports, but no test.
$ fallow mutation inspect f73493d4d103bf6f --replay --args '[1000, -10]'
...
Replay applyDiscount(1000, -10)
call original mutant
1 1000 1100
2 1000 1100
3 1000 1100
Witness: each side gave the same result on each call, and the sides differ. A test with this input can kill the mutant.
Replay contract 1: the clock starts at 1767225600000 ms and moves 1 ms at each read, Math.random seed 1, a new worker for each call, 5000 ms call limit.
- Each side runs three times, in turns, each call in a new worker with new modules. The clock and
Math.randomare fixed, so a value from the clock is the same on each call. - Without
--args, the replay uses up to 3 inputs of a--record-args valuesrun, and stops at the first witness. A mutant in a method or in top-level code needs--export. - Only Vitest and
node:testreplay. Other errors:FALLOW_MUTATION_REPLAY_STALE,FALLOW_MUTATION_REPLAY_UNSUPPORTED(bun test) andFALLOW_MUTATION_REPLAY_FAILED, each with exit code 2.
replay.verdict | Meaning |
|---|---|
witness | Each side repeats its result, and the sides differ. A test with this input can kill the mutant. |
no_witness_found | The inputs show no difference. Another input can still show one. It never means that the mutant is equivalent. |
unstable | The calls of one side differ, for example from crypto.randomUUID(). |
timeout | A call did not end in time. |
not_callable, not_replayable | The export is not a function, or the replay cannot run: reason says why. |
In JSON, the replay object lists each call with side, index, outcome, value and text. A value that JSON cannot hold is an object with a $replay tag, for example {"$replay": "undefined"}.
tasks
fallow mutation tasks [OPTIONS]
| Option | Description |
|---|---|
--report <PATH> | A saved fallow mutation --format json report (default: the report of the last run) |
tasks lists each survived and no_coverage mutant of a saved report, with the line before and after the change and the test files. It runs no code, and exits with code 0, also when tasks are open.
Mutation tasks: 6 open (5 survived, 1 without coverage)
...
1. src/lib/pricing.ts:2, function applyDiscount (survived) [f73493d4d103bf6f]
current: if (percent <= 0) return total;
changed: if (false) return total;
tests: src/lib/pricing.test.ts
- The lines come from the current file. A task whose file changed after the run is
staleand shows no code. --format markdownputs the lines in a fenced block.--format jsongives themutation-tasksoutput:mutant_id,file,line,column,operator,function,status,original_lines,mutated_lines,covering_test_files, andequivalence_hintwhen a survivor has one.- The JSON output also has a
scopeobject: thekindof the run (changed,allorpaths), thebase_refof achangedrun, andfiles.fileslists each file with a mutant result in the report, also a file without a task. A consumer can thus tell a mutant that a test killed from a file that the run did not mutate. - After a
--record-args valuesrun, a task can havewitness: a recorded input (args), the results of the current code (original) and of the changed code (mutant), andreplay_command. A test that assertsoriginalfor these arguments should kill the mutant. The Markdown output shows no values.
export
fallow mutation export [OPTIONS]
| Option | Description |
|---|---|
--report <PATH> | A saved fallow mutation --format json report (default: the report of the last run) |
export writes the report in the open mutation-testing-report-schema format, version 2, for mutation dashboards. It runs no code, and writes JSON for each --format.
- The format holds the full source of each mutated file. When a mutated file changed since the run, the command exits with code 2 and names the file.
- Lines and columns are 1-based. A column counts UTF-16 code units.
thresholdsishigh: 80,low: 60, andconfig.completionholds the completion of the report.
| fallow status | Schema status |
|---|---|
killed, timeout, survived, no_coverage, runtime_error, compile_error, pending | Killed, Timeout, Survived, NoCoverage, RuntimeError, CompileError, Pending |
flaky, pruned, equivalent, not_killed_by_target | Ignored, with the cause in statusReason |
In a partial run, each Survived and NoCoverage mutant gets a statusReason that says that the result is not conclusive. A dashboard counts NoCoverage in its score, and fallow does not, so the dashboard score can be lower.
test-run
fallow mutation test-run [OPTIONS] [PATH]... -- <COMMAND>...
test-run runs your Vitest command and records its dry-run facts for the next run. See Run the tests one time.
Options
| Argument | Description |
|---|---|
[PATH...] | Mutate only these files or directories instead of the changed code |
Scope
| Option | Description |
|---|---|
--all | Mutate every source file instead of the changed code |
--max-mutants <N> | Run at most N covered mutants, in rank order. Uncovered mutants do not count. |
--mutants-per-line <N> | Keep at most N mutants on each source line. The plan keeps the most productive mutants of the line (relational, condition, arithmetic and logical operators first). |
--function-scope | Widen each changed line to the whole function that holds it, so that a changed parameter or signature selects the mutants of the function. Only the changed-code scope uses it (default: the mutation.functionScope key, else the changed lines only) |
--allow-side-effects | Keep mutants in functions that reach a file system, process, network or database sink. A mutant can then remove a guard of a real side effect. |
--operators <NAMES> | The operators to use, comma-separated. Default: the default set. |
Run
| Option | Description |
|---|---|
--plan | Build the plan only: select, map and rank mutants. Runs no code |
--time-budget <DURATION> | Stop starting mutants after this time, for example 90s, 10m or 1h. The others are pending |
--mutant-time-cap <DURATION> | The cap of the measured test time of one mutant, for example 90s or 10m, or off (default: 3m, and off with --kill-matrix). A mutant whose estimate from the dry run is over the cap runs its covering tests in stages. |
--concurrency <N> | The number of mutation runner processes (default: one for each core up to 4, then half the cores and at least 4, and fewer when memory is low) |
--runtime <PATH> | The JavaScript runtime: a name on PATH such as node, or a file path (default from PATH: node for node:test, bun for bun test, and node, then bun, for Vitest) |
--allow-dirty | Run in a dirty git worktree. The run still reports the paths that it changed |
--reach-selection <MODE> | Select the dry-run test files by recorded function reach (off by default). on records in the cache which functions each test file enters, and leaves a test file out of a later dry run when its record proves that it cannot run a mutant. Values: off, on, check. |
--retry-scope <SCOPE> | The tests of the retry that confirms a survivor (default: file). file runs each test of the test files of the covering tests, so it also finds a test that reads a value that an earlier test of its file cached. |
--setup-timeout <DURATION> | Wait this long for each runner process to start, finish its dry run or reload, for example 5m on a slow or busy host (default: 2m) |
--runner-config <PATH> | The config file of the test runner, for example vitest.integration.config.mjs (default: the mutation.runnerConfig key, else the runner's own discovery). The file must be inside the project root. |
--runner-project <NAME> | Use only this Vitest project, as the Vitest --project flag does. Repeat the flag for more projects. |
Detection
| Option | Description |
|---|---|
--record-args <MODE> | Record the arguments of the changed exported functions in a record pass (off by default). shapes keeps their types, values keeps the values for fallow mutation inspect --replay. |
--verdicts <PATH> | A verdict document that marks mutants as equivalent. Equivalent mutants leave the score |
--typecheck | Type-check each survived mutant through the type-aware companion. A survivor that does not type-check becomes compile_error and leaves the score. |
--kill-matrix | Collect all killing tests and report redundant-test candidates for individual review. Run every covering test without stopping at a failure |
--kill-matrix-for <TARGET> | Check whether this test is redundant: a test file (each test in it) or a test id (file::name). Repeat the flag for more targets. |
--kill-matrix-full | With --kill-matrix-for: also run the other covering tests of a mutant that no target kills, and retry each survivor. Each mutant then gets a normal status, and the run has a score. |
Gates
| Option | Description |
|---|---|
--min-score <0-100> | Exit with code 1 when the mutation score is below this percentage |
Reruns
| Option | Description |
|---|---|
--resume | Continue an interrupted or partial run: reuse the killed and confirmed survived mutants in its journal and run only the others. A journal of other inputs exits 2 |
--recheck | Rerun the open tasks of a saved report (its survived and no_coverage mutants) against the current tests. The worktree may change test files only. |
--report <PATH> | The saved report of --recheck (default: the report of the last run). A recheck without --mutant replaces this file and the report of the last run |
--mutant <ID> | Recheck only these mutant ids of the report, comma-separated or repeated (default: each open task). The saved report then stays as it is, so fallow mutation tasks keeps the other open tasks |
--compare <PATH> | Compare this run with a saved complete report: list each mutant that the report detects (killed or timeout) and this run does not (survived or no_coverage), with its earlier killing tests. A report or a run that is not complete exits 2 |
The global options are in these groups: Project, Output, Scope, Baselines, Gates, Duplication, Type-aware, Performance.
fallow mutation also accepts these global options: --root, --config, --format (human and json), --quiet, --no-cache, --changed-since, --diff-file, --diff-stdin and --output-file. --workspace and --changed-workspaces exit with code 2: pass a package directory as a path.
Option details
Changed-code scope
Without --all or a path, the run mutates the lines that changed since the base ref. Fallow finds the base in the same way as fallow audit. The changed-code scope, --all and a path cannot go together.
--diff-file,--diff-stdinand--diff-file -supply the patch. An empty patch selects no mutants. When fallow cannot resolve the paths of the patch, it exits with code 2 andFALLOW_MUTATION_DIFF_NOT_APPLIEDbefore a test runs.- A diff that fallow makes uses Git copy and rename detection (
-M -C), so the unchanged lines of a copied file get no mutants. A supplied patch is used as written: make it withgit diff -M -Cto keep this detection.
The run mutates JavaScript and TypeScript files, Svelte module files (.svelte.js, .svelte.ts), and the script blocks of Vue, Svelte and Astro components. A Vue compiler macro call (defineProps and the others), an expression that holds a Svelte rune call, and an exported declaration in Astro frontmatter give no mutant.
Function scope
--function-scope, or mutation.functionScope: true, widens each added line to all mutants of the innermost function that holds it. A changed parameter or signature line then selects the mutants of the function.
- When no function holds the line, the largest function that starts on the line counts. A line outside each function selects only its own mutants. A nested function is part of the outer function.
--all, a path and--recheckdo not accept the flag. No flag turns the config key off.
Runners
| Runner | mutation.runner value | Supported versions |
|---|---|---|
| Vitest | vitest | 4.1.0 and later, before 6.0.0, in Node mode |
node:test | node-test | Node.js 22.18.0 and later, before 27.0.0 |
bun test | bun-test | Bun 1.4.0 and later, before 2.0.0 |
An unsupported version stops the run with FALLOW_MUTATION_RUNNER_UNSUPPORTED before the first mutant. Vitest 4.0 ignores the test-id filter, so each mutant would look killed. Bun 1.3 gives no test results for a run that stops at the first failure.
The default value auto selects the runner in this order:
- A
vitestdependency in the rootpackage.jsonselects Vitest. - Otherwise, the test module that most test files import:
vitestorvite-plus/test,bun:testornode:test. - Otherwise, a
vite-plusdependency in the rootpackage.jsonselects Vitest. A project can use Vite+ only to build, lint or format, so the test imports come first. - Otherwise, a
bunfig.toml,bun.lockorbun.lockbfile at the root selectsbun test. - Otherwise, a
node --testorborpcommand in apackage.jsonscript selectsnode:test. - Otherwise, Vitest.
Runner rules:
- Vitest: a test that loads a source file with a native
requiregets the mutated file only on Node.js 22.15 or later. Otherwise the report lists the file inunloaded_paths. Whentypecheck.enabledis set, the run does not execute the type-check pass, andrunner.noteshastypecheck-not-run. node:testandbun testrun each test file in its own process, and find the test files with the default patterns of the runner. A test file that the plan maps and no pattern matches makes the runpartialwithtest-files-not-discovered.bun testreads the projectbunfig.tomlonly from its working folder. Fallow starts each test file in the folder of the nearestbunfig.tomlbetween the test file and the root, else at the root, ascd <package> && bun testdoes. A workspace package with its ownbunfig.tomlthen gets its[test] preload. Bun does not merge that file with the root file. For the tests of such a package,process.cwd()is the package folder, and Bun loads the.envfiles of that folder.- Node.js and Bun cannot load a Vue, Svelte or Astro component, so the plan lists each component in
skipped_fileswith the reasonrunner-cannot-load. node:testgives each test process the module loading flags of the firstnode --testscript (--experimental-transform-types,--experimental-strip-types,--import,--require,--experimental-loaderand--conditions).NODE_OPTIONSalso reaches each test process.- With Vitest and
node:test, a Node.js child process of a test loads the mutated files, and its code counts as coverage of that test. - A type test file (
*.test-d.ts,*.spec-d.ts) is not a test file of the plan. - A Vitest bench file (
*.bench.*,*.benchmark.*) is not a test file of the plan. A bench file with a test marker, such asperf.bench.test.ts, stays a test file. - A file below
__tests__is a test file of the plan only when its name has a test marker (.test.,.spec.,_test.,-test.,_spec.), or when a test pattern of the runner selects it: a Vitestinclude, a Jest default, or a file that anode --testscript names. Other files there, such as__tests__/support/test-gateway.ts, are test helpers.
--runtime takes a name, which is a PATH lookup, or a path with a separator, which is a file relative to the current directory. A runtime of the wrong kind for the runner exits with code 2 and FALLOW_MUTATION_RUNTIME_NOT_FOUND.
Runner config
--runner-config <PATH>, or mutation.runnerConfig, selects the config file of the test runner, for example vitest.integration.config.mjs. The flag wins over the config key.
- The file must exist inside the project root. Otherwise the run exits with code 2,
FALLOW_INVALID_MUTATION_OPTIONSand the contextmutation.runnerConfig. Only Vitest accepts it. - A relative flag path resolves against the project root, then against the current directory.
- The selected config sets the test files that Vitest lists. When it leaves out a test file of the plan, the run is
partialwithtest-files-not-discovered.
Runner projects
--runner-project <NAME>, or mutation.runnerProjects, uses only the named Vitest projects, as the Vitest --project option does. A name can hold a * wildcard. Only Vitest accepts it.
Fallow cannot instrument a project that comes from a separate config file, so a run that uses one fails at setup. Leave such projects out of the selection. A name that matches no project also fails the run at setup.
Operators
A run that names no operator uses the default set. A list in --operators or mutation.operators replaces the default set. To add an opt-in operator, name each default operator and the opt-in operator.
| Operator | Set | Change |
|---|---|---|
arithmetic-operator | default | a + b to a - b, and the other pairs. % becomes *. Compound assignments swap the same way. |
relational-operator | default | a < b to a <= b, and the other pairs. An equality also becomes its negation, false and true. |
logical-operator | default | && and || swap. ?? becomes &&. |
negate-condition | default | The test of an if, a ? : or a loop to true and false. An operand of && to true, of || to false. |
unary-operator | default | !x, -x and ~x to x. -x and +x swap. |
update-operator | default | i++ to i--, and the reverse. |
removed-call | default | A call statement removed. |
return-value | default | return expr and the body of x => expr to undefined. |
boolean-literal | default | true to false, and the reverse. |
string-literal | default | A string or template literal emptied, or an empty one filled with "fallow". |
optional-chaining | default | a?.b to a.b. |
regex-literal | default | One token of a regex literal: an anchor or a quantifier removed, {n,m} to {n}, a class negated, or \d to \D and similar. |
removed-chain-link | default | One link of a call chain in a module-level const removed, for example z.number().int() to z.number(). |
block-statement | opt-in | The statements of a block or function body removed. |
array-literal, object-literal | opt-in | [x] to [], [] to ["fallow"], and an object literal to {}. |
method-expression | opt-in | A method to its pair (startsWith and endsWith, every and some, min and max and others), or s.trim() to s. |
switch-case | opt-in | The statements of a case clause removed, so it falls through. |
call-expression | opt-in | A call in an expression position to (void 0). |
throw-statement | opt-in | throw new X(...) removed. |
regex-constructor, regex-assertion | opt-in | The regex changes of a new RegExp("...") pattern. A lookaround negated, or \b and \B swapped. |
nullish-fallback | opt-in | a ?? b to a. |
These rules stop a mutant that only gives an endless loop, a syntax error or the same result:
- A loop test that is a comparison gets no
truemutant. Only a comparison or a!xoperand of&&or\|\|gets anegate-conditionmutant. - An expression with a string or template operand gets no
arithmetic-operatormutant. A tagged template gets nostring-literalmutant. - A
console.*ordebug(...)call gives no mutant, also in its arguments. block-statementandswitch-casegive no mutant for a range that declares a binding.call-expressiongives no mutant whereremoved-callorreturn-valuegives the same result.- Fallow skips equivalent mutants that it can prove: a
caselabel with the same body asdefault, the!=mutant of a countedforloop, a zero comparison on the length of a known array, and a lookup before.filter(Boolean).
Operators gives the rules of each operator and each regex token. Skipped equivalent mutants gives the conditions of each skip.
Mutants per line
--mutants-per-line <N>, or mutation.mutantsPerLine, keeps at most N planned mutants on each source line. The plan chooses before the dry run and before --max-mutants.
- A line keeps its mutants in operator order: relational, condition, arithmetic and logical operators first, the opt-in operators last. A stable hash of the mutant id orders the mutants of one operator.
- A left-out mutant is
pendingwithpending_reason: "sampled-out", orno_coveragewhen no test covers it.summary.sampled_outcounts these mutants, and the completion ispartialwithsampled-out. --recheckdoes not accept the flag.
Mutant limit and time budget
Before the mutants run, fallow runs your tests once with no active mutant (the dry run). The dry run finds the covering tests of each planned mutant, with three times the test timeout of your project.
--max-mutants <N>counts only covered mutants. A cached result uses a place in the limit. A run can execute a mutant that--planshows aspending, because the plan comes before the dry run.--time-budgetstarts the mutants with the lowest estimated test time first. It stops new mutants early, to keep time for the retries. A mutant that started continues until its timeout.--setup-timeoutlimits the start, the dry run and each reload of a runner process. A first process past the limit stops the run withFALLOW_MUTATION_RUNNER_FAILED. A restarted process past the limit givesruntime_error.
Dry run gives the timeouts of the dry run, the time limits of a mutant run and the self-check of the runner.
Retries
A survived or timeout mutant runs a second time in a new runner process, because host load can make a test time out. The second run of a timeout gets twice the time. A killed result gets no retry.
| First run | Second run | Final status |
|---|---|---|
| any | runtime_error | runtime_error |
survived | survived or timeout | survived |
survived | killed by a test of the first run | flaky |
survived | killed by a test that the first run did not execute | killed |
timeout | timeout | timeout |
timeout | killed | killed |
timeout | survived | flaky |
- The second run of a survivor runs each test of its covering test files. A kill by a test outside
covering_testscounts only when those tests pass with no active mutant. "retried": truemarks a mutant with both runs. Itsattemptsarray has thestatus, theduration_ms, andkilled_byandfailure_kindfor a kill, of each run.- With Vitest, an endless loop through your source code stops when the test uses more CPU time than 1.5 times its dry-run time, plus 500 ms. Such a timeout gets no second run when the covering tests take 200 ms or less.
- A loop timeout stops the other tests of the run. Then fallow runs the tests that did not run, with the same mutant and limits. A kill of that run makes the mutant
killed. - When the runner process gives no result before its time limit, the timeout always gets the second run, unless the time budget ends first.
Redundant test candidates
--kill-matrix runs all covering tests of each mutant with bail disabled, and records each test that kills each mutant. It can take much longer.
kill_matrix field | Content |
|---|---|
status | complete, incomplete or unavailable. Without the option, unavailable with the reason kill-matrix-disabled. |
reasons | The limits of the evidence, such as incomplete-mutant-results, baseline-failure or partial-mutation-run. |
tests | For each test: test_id, file, kills, unique_kills, subsuming_tests and notes. |
candidates | The tests whose kills other tests also make. Incomplete evidence gives no candidates. |
coverage_without_kills | The tests that ran mutated code and killed nothing. |
Review each candidate alone. Two candidates with the same kills protect each other, so do not remove both. A candidate does not prove that you can remove the test. Each mutant records killing_tests and kill_matrix_complete, and killed_by keeps the first killing test.
Check named tests
--kill-matrix-for <TARGET> checks whether the named tests are redundant, without a full kill matrix. A target is a test file or a test id (file::name). Repeat the flag for each target. It cannot go together with --kill-matrix.
- Only the mutants that a target test covers run. The others are
prunedwithno-target-coverage. kill_matrix.targetslists each target with itstest_ids,statusandreasons. A target that selects no test isincompletewithunmatched-target, andnot-a-test-fileorno-planned-codewhen fallow knows why.target_only_killsof a test lists the kills that only other targets share. The test stays redundant only while one of those targets stays.- When no target selects a test, the run exits with code 2 and
FALLOW_MUTATION_TARGET_UNMATCHED. A test id target with a duplicate name exits withFALLOW_MUTATION_TARGET_DUPLICATE_TEST_ID.
Target modes
target_mode | When no target kills the mutant | Score |
|---|---|---|
target-first (default) | The mutant is not_killed_by_target. No other test runs. | None. --min-score exits with code 2. A mutation.minScore gate is skipped. |
full (--kill-matrix-full) | The other covering tests run, and each survivor gets a second run. | As in a normal run. |
In both modes, the other covering tests run after a target kill, up to the first failure. For deterministic tests, both modes give the same kills, unique_kills and target_only_kills.
Type check of survivors
--typecheck, or mutation.typecheck: true, type-checks each survivor after the tests, with the program of type-aware analysis. It compares the type errors of the mutated file with those of the original file.
- A survivor that adds a type error becomes
compile_error, with at most 8 codes intype_error_codes. It leaves the score and counts as covered. The check reads only the mutated file. - A survivor that the check cannot check stays
survived. The reasons areno-project,not-type-checked,source-changed,file-missingandunsupported-file(a component). - Without the program, the run exits with code 2 and
FALLOW_MUTATION_TYPECHECK_UNAVAILABLEbefore the tests. A check that fails after the tests makes the runpartialwithtypecheck-failed. - The
typecheckobject hascompleted,survivors,checked,compile_errors,hintedandskipped.
A survivor can get an advisory equivalence_hint. The status stays survived, and the score does not change. The hint can be wrong: read the code, then record a verdict.
type-non-nullish: the mutant removes?.or?? b, and the declared type of the value excludesnullandundefined. It needsstrictNullChecksandnoUncheckedIndexedAccessin a TypeScript file.constant-parameter: anegate-conditionsurvivor on a parameter test, when each visible call passes the same literal. It uses the call evidence of theconstant-parameterrule and needs no option.
Result cache
A run stores the result of each killed, not_killed_by_target and confirmed survived mutant in .fallow/mutation/results.json, at most 20,000 entries. A later run reuses a result when its key is the same. It also reuses the dry run of each unchanged test file from .fallow/mutation/dry-runs.json, so a run with no change starts no dry run.
- The key covers the mutant, its source file, the covering tests and the files that they import, the runner setup and config files at the root, the selected runner config and projects, the lockfile, the root
tsconfig.jsonchain, and the runner, runtime and fallow versions. - The key does not cover dynamic imports that fallow cannot resolve, files that tests read, or config files below the root. Pass
--no-cachewhen such a file changes. - A reused result has
"cached": true. Thecacheobject hashits,storedandnot_keyed, anddry_run_hits,dry_run_misses,dry_run_storedanddry_run_miss_reasonsfor the dry-run cache.
Result cache lists each part of the key.
Resume a run
Each run writes its final results to .fallow/mutation/journal.jsonl, also with --no-cache. --resume reuses them and runs only the other mutants.
- The journal must come from a run with the same fallow version, runner, runtime, planned files, runner config, scope, operators and
--allow-side-effects. Otherwise the run exits with code 2 andFALLOW_MUTATION_RESUME_MISMATCH. - The limits (
--max-mutants,--mutants-per-line,--time-budget,--concurrency) are not inputs, so you can continue with other limits. - A reused result has
"resumed": true. Theresumeobject hasjournal,reused,rejectedandnote. - A
completerun removes the journal. A partial or interrupted run keeps it.--plan --resumeexits with code 2.
Resume journal gives the other rules of the journal.
Recheck after new tests
--recheck reruns the survived and no_coverage mutants of a saved report against the current tests. --mutant <ID> selects mutants by id.
- A source file that changed after the report exits with code 2 and
FALLOW_MUTATION_SOURCE_CHANGED. An uncommitted change outside the test files exits withFALLOW_MUTATION_NON_TEST_CHANGE. - The other mutants keep their earlier status, with
carried: true. A carried kill stays, also when you made a test weaker. After such a change, run without--recheck. - A recheck without
--mutantreplaces the saved report. Therecheckobject gives, for each mutant, the earlier status, the new status and anoutcome:killed,survived,no_coverage,tests_fail_on_originalorunsettled. --recheckcannot go together with a scope option,--plan,--resume,--allow-dirty,--max-mutantsor--min-score.
Compare with a saved report
--compare <PATH> shows when a change of the tests weakens them: a mutant that a test killed before survives now.
$ fallow mutation src/lib/pricing.ts --compare .fallow/before.json
...
Compare with the saved report
16 mutants in both runs
2 regressed: detected before, not detected now
src/lib/pricing.ts:6 c0a33aa7f9d164d9 killed -> survived, killed before by src/lib/pricing.test.ts::shipping
- Save the earlier report with
-oin the cache directory, because each run replaces the saved report. The compare matches mutants bymutant_id. - Both reports must be
complete. Otherwise the run exits with code 2 andFALLOW_MUTATION_COMPARE_INCOMPLETE. - A regression does not change the exit code. Read
compare.regressedto fail a CI job. Each entry ofcompare.mutantshas achange:regressed,inconclusive(aflakymutant),addedorremoved.
Safety rules
- A run refuses a git worktree with uncommitted changes, and exits with code 2.
--allow-dirtyturns off this check. After the run, the report lists each path that the tests changed, also an ignored file such as.env. - Fallow does not write to project files. The changed copies live in the fallow cache directory. A cache directory that holds the project or a planned file exits with code 2 and
FALLOW_MUTATION_UNSAFE_CACHE_DIR. A symlink at<cache>/mutation,<cache>/mutation/runsor<cache>/mutation/companion, or a link on the way to them that resolves outside the project, into Git metadata or intonode_modules, gives the same code before the first write. The removal of old run directories never follows a symlink. - Each test runner gets its own temp directory, and fallow ends each test process when the run ends, also on a signal.
- A mutant in a function that calls a file system, process, network or database API is
prunedwithside-effect-sink. A database write counts in a module that imports a database client package.--allow-side-effectskeeps these mutants. No config key can do this. Side effects and Database writes give the rules. - Do not redirect the report with
>: the shell creates the file first, and the worktree check refuses the run. Use-o .fallow/mutation.json.
--record-args values records up to 8 inputs of each changed exported function in a separate test pass, for the replay and the tasks. The inputs stay for 7 days in a file that only you can read, without values under secret key names. Do not record in a project whose tests pass real credentials. Argument recording gives the limits, and What a recording leaves out gives the redaction rules.
Verdict document
--verdicts <PATH> reads a document that marks mutants as equivalent: no test can detect them.
// verdicts.json
{
"schema_version": "1",
"verdicts": [
{ "review_key": "cc6df8e855ee87fa", "verdict": "equivalent", "note": "percent 0 gives the same total" }
]
}
The review_key is the mutant_id. The id stays the same until the enclosing function changes, so one document serves many runs.
| Mutant status | Verdict result |
|---|---|
survived, no_coverage, flaky | The status becomes equivalent. The mutant leaves the score and the coverage, and loses its hint. |
killed, timeout, compile_error | contradicted. The status stays. |
pending, runtime_error, pruned | deferred. |
| No match | unmatched. |
An invalid document exits with code 2 before a test runs. The run executes the marked mutants and applies the verdicts after the run.
Output
$ fallow mutation src/lib/pricing.ts
Mutation testing (ran the project tests)
Scope: the given paths
Score 66.7% killed 10 survived 5 timeout 0 complete
Coverage 93.8% no coverage 1
● Survived (5)
src/lib/pricing.ts
#2 2:7 applyDiscount negate-condition if (percent <= 0) return total; -> if (false) return total;
id f73493d4d103bf6f
covered by 1 test: src/lib/pricing.test.ts::discount
...
● No coverage (1): no test reaches these mutants
src/lib/pricing.ts 1 mutant test reach: 1 direct
Test kill evidence: unavailable
kill-matrix-disabled: this run did not collect all killing tests. Use --kill-matrix.
Next
Inspect a survivor (runs no code): fallow mutation inspect f73493d4d103bf6f
Scoreis the share of the tested mutants that a test detects.Coverageis the share of the planned mutants that a test reaches. The last word of theScoreline is the completion.- The output shows the 10 best-ranked survivors, grouped by file. Each gives its rank, place, function, operator, change, id and covering tests. The JSON report lists all survivors.
No coveragegives the test reach of each file.- On stderr, a run prints progress lines such as
fallow: mutation: 15/15 mutants done (2s).--quietand--format jsonprint none.
Saved report
Each run saves its full JSON report to .fallow/mutation/last-report.json, and replaces the earlier one. The cache directory has its own .gitignore, so this file does not make the worktree dirty. A -o file outside the cache directory does.
Plan output
--plan lists each mutant with its place, function, operator and id, and runs no code. The JSON plan has a runner object, from the package.json of the installed Vitest:
{ "name": "vitest", "package": "vitest", "installed_version": "4.1.12", "supported_range": ">=4.1.0 <6.0.0", "supported": true, "message": null, "help": null }
supported is false outside the range, and null for node-test and bun-test. Then message and help give the problem and the install step. The plan still exits with code 0. fallow doctor gives the same verdict in its mutation-runner check.
Statuses
| Status | Meaning | In the score | In the coverage |
|---|---|---|---|
killed | A covering test failed. | yes | yes |
timeout | The run passed its time limit, also in a second run. It counts as detected. | yes | yes |
survived | Each covering test passed, also in a second run. | yes | yes |
no_coverage | No test reaches the mutant. | no | yes |
runtime_error | The runner failed for a reason outside the tests. | no | yes |
flaky | The second run gave another result. | no | yes |
compile_error | The mutant survived, but adds a type error. Only --typecheck sets it. | no | yes |
not_killed_by_target | No target test of --kill-matrix-for kills the mutant. | no | yes |
pending | The mutant did not run: a limit or the time budget ended first. | no | yes |
equivalent | A verdict marks the mutant as equivalent. | no | no |
pruned | A static rule removed the mutant. | no | no |
The prune_reason of a pruned mutant is one of these:
side-effect-sink: the function calls a file system, process, network or database API.framework-config: an export that a framework reads as config, such asexport const revalidate = 60, or the config of a tool config file such asvite.config.ts.build-tool-only: only tool config files reach the file, for example a Vite plugin module.dead-code: no entry point reaches the file.generated: the file is generated code.no-target-coverage: no target of--kill-matrix-forcovers the mutant.not-selected: a--recheckselected other mutants.
Pruned mutants gives the rule of each reason. Statuses shows how each status counts for the cache, the journal and the exit code.
The score is (killed + timeout) / (killed + timeout + survived), and the coverage is covered / (covered + no_coverage). Both are fractions from 0 to 1 in JSON. A run without a tested mutant has no score. The dry run decides the coverage of each planned mutant, so a run with --max-mutants reports the coverage of the full plan.
Completion
completion.status is complete or partial. Only a complete run makes an empty survivor list conclusive. A partial run lists its reasons: mutant-limit, time-budget, sampled-out, runtime-error, baseline-failure, typecheck-failed or test-files-not-discovered.
test-files-not-discovered: the runner did not list a test file of the plan, so its tests never ran. Select its config with--runner-config.- A test that fails in the dry run is in
baseline_failures, and decides no mutant status. See Baseline failures. - The
errorsentryduplicate-test-idsnames tests with the same full name. The entryskipped-testsnames skipped tests in a changed test file. Neither stops the run. - When a restarted runner process fails, fallow suggests
--concurrency 1, because parallel processes can share state.
Test reach of no-coverage mutants
Each no_coverage mutant has a test_reach object with the static reason. It never changes the score or the coverage.
reach | Meaning |
|---|---|
none-file | No test loads the file. |
mocked-only | Tests reach the code only through a mock. tests and mocked_targets name them. |
none | A test loads the file, but no test reaches this code. |
direct, transitive | A test refers to the export, but no test ran the code of the mutant. |
export_name names the export when the mutant is in an exported declaration. Treat the set of classes as open.
JSON output
With --format json, the output has these top-level fields:
| Field | Content |
|---|---|
kind | "mutation". --plan gives "mutation-plan", inspect gives "mutation-inspect", and tasks gives "mutation-tasks". |
schema_version, version, elapsed_ms | The version of this output format, the fallow version and the run time. |
completion | complete or partial, with the reasons. |
scope, runner | The selected code, and the runner with its version. With Vitest, runner.worker_modes gives the runs and duration_ms of the mutant runs in each worker mode: isolated (a new worker for each test file), shared (one new worker for the test files of the run) and reused (the kept worker of the runner process). |
summary | counts for each status, score and coverage as fractions from 0 to 1, and sampled_out. |
mutants | One object for each mutant: mutant_id, file, line, column, operator, function, change (from and to), status, covering_tests, killing_tests, retried. Each mutant also has rank, span, function_line, duration_ms and cached. A no_coverage mutant has test_reach. |
functions | The counts and the score of each function. |
kill_matrix | The evidence of --kill-matrix: status, reasons, tests, candidates. Without the option, status is unavailable. |
cache | hits and stored of the result cache, the dry_run_* counts of the dry-run cache, and reach_selection. |
worktree | The paths that the tests changed. |
errors, baseline_failures | The errors of the run, and the tests that fail without a mutant. |
typecheck, resume, recheck, verdicts | The result of --typecheck, --resume, --recheck and --verdicts. |
timings | The time of each step. |
files | Each mutated file with its SHA-256 digest at plan time. inspect compares the digest with the current file. |
skipped_files, unloaded_paths, unmatched_paths, no_test_files | The selected files without mutants, the files that the runner never loaded, the path arguments that select no file, and true when the project has no test files. |
A change side that is project code is a placeholder, such as <condition>, <expression> or <string>, so the report holds no source text. The change of a mutant lists each value. --min-score uses a percentage. summary.score is a fraction. The JSON output reference has each field.
Exit codes
| Code | Meaning |
|---|---|
0 | The plan, the run or the subcommand completed. Survivors do not change the exit code. |
1 | --min-score or mutation.minScore is set, and the score is lower. |
2 | Invalid input or an execution error, for example a dirty worktree without --allow-dirty, an unsupported runner version, an invalid verdict document, or a --resume journal of other inputs. |
128 + signal | A signal stopped the run (130 for SIGINT). A stop during the mutant runs prints the report of the finished mutants. |
A run with no score exits with code 0. A run in which baseline failures leave no mutant with a test result exits with code 2 and FALLOW_MUTATION_BASELINE_FAILED. The sections above name the other error codes. Exit codes has the meaning of each code.
Examples
# Show the plan of the changed code, and run nothing
fallow mutation --plan
# Mutate the code that changed since main
fallow mutation --changed-since main
# Mutate one directory, and stop after 10 minutes
fallow mutation src/billing --time-budget 10m
# Fail when the score is lower than 80 percent
fallow mutation --all --min-score 80
# List the open tasks, write tests, then run the open tasks again
fallow mutation tasks
fallow mutation --recheck
# Find the tests that kill no mutant that other tests do not kill
fallow mutation --all --kill-matrix --format json --quiet
Related
- Mutation testing: what a survivor means, and how to act on it.
fallow health: the mutation score next to the CRAP score.- Config: mutation: the
mutationconfig keys.