On this page

Compatibility

Mootant runs with Vitest 5, Jest 29.7 or later, or Node Test, the test runner built into Node.js. It uses your existing tests and configuration, and checks that the tests pass without mutants before testing any changes.

Tests run in the project’s own directory. A mutant in code that writes or deletes project files, such as a build script that a test runs, changes those files for the tests after it, and the change stays. Keep such code out with an ignore comment.

A test whose path depends on timing, such as a timer that races the test’s own waits, can reach a mutant in one run and miss it in the next. Such a mutant may read as not covered, or as killed in one run and not in another.

Node.js

Mootant supports Node.js 20 from 20.19.0, and Node.js 22.12.0 or later: ^20.19.0 || >=22.12.0. Vitest 5 itself needs Node.js ^22.12.0 || ^24.0.0 || >=26.0.0, so Node.js 20 works only with Jest and Node Test.

From Node.js 22.8, the Vitest and Node Test processes that run the tests keep Node’s module compile cache in a temporary directory of the run, so a process reuses the code an earlier one compiled. The cache is removed with that directory when the run ends. Processes that the tests start get no cache, and module.getCompileCacheDir() in a test gives a directory instead of undefined. NODE_DISABLE_COMPILE_CACHE=1 turns the cache off, and a NODE_COMPILE_CACHE you set is used as it is.

The installer of the agent skill, npx skills, needs Node.js 22.20 or later. On an older version, copy skills/mootant from the repository to .claude/skills/mootant for Claude Code, or to .agents/skills/mootant for Codex, Cursor and GitHub Copilot.

Source files

SourceExtensionsSupport
JavaScript.js, .jsx, .mjs, .cjsList and run mutants.
TypeScript.ts, .tsx, .mts, .ctsList and run mutants. Types are not mutated.
Vue.vueScript blocks and template expressions; see Vue and Svelte.
Svelte.svelteScript blocks and template expressions; see Vue and Svelte.
Astro.astroList mutants in frontmatter and script blocks; see Astro.

Vitest

Mootant uses the project’s installation of Vitest 5, its configuration and Vite plugins. Other Vitest major versions are not supported.

Projects on the forks and threads pools can run. Mootant always runs tests in its own forks pool with isolate: true, and warns when that differs from your configuration. It does not support:

  • Browser mode
  • Custom Vitest test runners
  • Other pools
  • experimental.viteModuleRunner: false, which bypasses Vite transforms

Any of these in one project stops the whole run with an error.

With --parallel-units, a worker process may start before Vitest gives it a test file, but loads no code of the project until then; process.uptime() and performance.now() count from its start.

For a custom Vitest configuration path, use vitestAdapter.

Unhandled errors

Mootant uses dangerouslyIgnoreUnhandledErrors and onUnhandledError from your Vitest configuration to decide whether an unhandled error or rejection kills a mutant. If a test registers its own process.on handler for the event, Mootant leaves the error to that handler, as Vitest does.

Flags in test scripts are not read. If you set --dangerouslyIgnoreUnhandledErrors only in a test script, unhandled errors still kill mutants and raise the score.

All mutants share one Vitest session. An onUnhandledError handler that keeps state between calls may behave differently from a plain run with that mutant. For example, a handler that ignores only the first occurrence of an error may have already seen it during an earlier mutant’s run.

Test selection

Mootant may miss a test that loads a mutated file only through:

  • A computed import().
  • A vi.mock whose __mocks__ file loads the original module.
  • A vi.mock with an inline factory that has no parameters and does not call importActual directly, even if a helper loads the original module.

Such a test is still selected if it imports another mutated file in the paths you pass to Mootant. Narrowing those paths may leave mutants uncovered or let them survive, lowering the score. Re-check these mutants with the same paths as the full run.

Child processes

Child processes and workers started by a test run the original code.

Jest

Mootant detects Jest when test scripts call it, or when the project depends on Jest, has a jest.config.* file in its root or a jest key in package.json. It uses the project’s installation of Jest 29.7 or later and its configuration: one project or several projects, transformers such as Babel, @swc/jest and ts-jest, the jsdom and node test environments, and ES modules under --experimental-vm-modules. Tests run with jest-circus, Jest’s default test runner. Mootant does not support:

  • jest-jasmine2
  • A custom runner, such as jest-runner-eslint
  • A custom testRunner that is not plain JavaScript
  • Vue and Svelte components

A project on jest-jasmine2 or a custom runner is skipped with a warning, and a run with no other project stops with an error.

Worker reuse

Mootant reuses Jest workers across mutants. Each test file runs many times against one global setup. If a test file fails when repeated without mutants, Mootant stops with an error that names the file.

Changes a test leaves in its process, such as a property of http.globalAgent, can affect later mutants on the same worker. Enable freshWorkers in jestAdapter to start a new worker for every run of a test file. This prevents process state from leaking between runs, but is slower. Global setup and files on disk remain shared.

A worker uses about 600 MB with a large module graph. Lower --concurrency to use fewer workers. --fast and --parallel-units have no effect with Jest.

Mutation limits

  • Child processes and workers started by a test run the original code.
  • Mutants in code run only by global setup stay uncovered.
  • Mutants in source files excluded from transforms by transformIgnorePatterns stay uncovered.
  • Mutants in code run by a custom test environment get an Error verdict.

Mootant disables ts-jest’s type checking. Type errors in test files do not fail the run, and mutants that only break types survive.

Cache invalidation

Delete the cache directory after changing:

  • A file or environment variable read only by global setup.
  • An environment variable read only by a transformer’s configuration, a test environment or a resolver.
  • A transformer without getCacheKey, or a plugin or preset of a transformer, such as Babel’s: Jest keeps the transforms it cached.
  • A file in node_modules that tests read other than by loading it as a module, such as a data file.
  • File or directory names in the project root.

Test commands

When a test script calls Jest through another script, Mootant does not preserve the environment variables set along the way. Jest also runs from the project root, even if the test command includes cd.

Use jestAdapter to set the test command and environment variables explicitly.

Node Test

Mootant detects Node Test when test scripts use node --test, tsx --test, bnt or borp, or test files import node:test. If runners are equally likely, such as tests that import node:test in a project with Vitest installed, Mootant uses the first of Vitest, Jest and Node Test and prints a note; set run.runner to choose. Each mutant runs a test file in its own process, which may start before the mutant is known, but loads no code of the project until then; process.uptime() and performance.now() count from its start. --fast has no effect with this runner.

TypeScript needs Node.js type stripping or tsx. Other loaders, such as ts-node, and tsx with .cts files or with .ts files whose nearest package.json lacks "type": "module", stop the run with an error.

Child processes and workers started by a test run the original code. Tests slower than 60 seconds need the --test-timeout flag of Node.js in a node --test or tsx --test command or in the adapter’s execArgv, or --timeout in a borp command. These are not Mootant CLI options.

Use nodeTestAdapter to set another test command, test files, Node.js flags or environment variables.

Vue and Svelte

Mootant reads JavaScript and TypeScript in <script> blocks. It also mutates template expressions when the project has:

  • Svelte 5 or later for Svelte templates
  • @vue/compiler-dom 3.5 or later for Vue templates

Running the mutants of a component is supported only with Vitest, and requires the framework’s Vite plugin in the project’s Vitest configuration. Under Node Test, these mutants stay in the run as uncovered. Calls the compiler needs as written, such as Vue’s defineProps() or a Svelte rune, stay in place; code inside them can still be mutated.

A Svelte component or Vue template that does not compile with its mutants gives them an Error verdict with the compiler’s message. Vue templates reach mutants through Math[Symbol.for('mootant')], so tests that replace Math hide them.

To leave template expressions unchanged, set settings.templates to false. Scripts can still be mutated.

Astro

mootant list reads code between the leading --- lines of an Astro file and in its <script> blocks. Astro templates are not mutated. mootant run skips Astro components with a warning and runs the other files.