Skip to content

Configuration

A .vitest-dedup.json file is found by walking upward from the analyzed directory, or named with --config. A relative --config path is resolved against the analyzed directory, not the shell’s working directory. Automatic discovery chooses the nearest file up to the filesystem root, including files above a Git repository. Use --config to select a specific file instead. Command-line flags override it.

{
"include": ["src/**/*.test.ts"],
"exclude": ["**/fixtures/**"],
"threshold": 0,
"rules": { "subsumed-test": "warning" }
}

Every key is optional, and an unknown key is an error.

Key Meaning
include, exclude Globs relative to the analyzed directory.
threshold A percentage from 0 to 100 of eligible cases in error-severity duplication; see the quality gate.
rules Maps a rule id to off, warning or error.
vitestMajor 3, 4 or 5: the Vitest major of files whose metadata names none; see Vitest major.

Files matched by .gitignore or by a .vitest-dedupignore file in the same syntax are skipped as well. Ignore rules follow git. Inside a repository (the nearest directory at or above the analyzed one holding .git, as a directory or as the file a worktree or submodule uses, or an existing .jj entry), the .gitignore files from that repository’s root down to the analyzed directory apply, a deeper file overriding a shallower one, and so does the .git/info/exclude of a repository whose .git is a directory. A .gitignore above the repository root does not, so a project nested in a larger repository is not affected by that repository’s rules. .vitest-dedupignore and .ignore files are not git’s and are read from every ancestor directory. Outside any repository every .gitignore in the ancestor directories applies. A rule that names the analyzed directory itself does not remove it.

Repository ignore inputs must be regular files, not symlinks or special files. User-configured global ignore files may be symlinks to regular files; the same limits apply to their targets. Non-file global paths (for example /dev/null) are skipped without reading, as before. Each file is limited to 1 MiB, 8,192 lines, 4,096 patterns and 8 KiB per line; one discovery may read at most 8 MiB and 32,768 lines of ignore and repository-pointer inputs. A refused or malformed ignore file produces a diagnostic and marks discovery incomplete. Its rules are not applied; readable tests remain discoverable using the other valid rules and configured include/exclude globs.

threshold is compared with the share of eligible runtime cases that sit in an error-severity finding.

  • A case is a declaration, or one row of a test table: two rows of one table are two cases, and a case named by several findings counts once. A suite finding counts the tests inside its copies, once, whichever of the suite and its tests is at error. A redundant-hook finding is not a test case: it adds nothing to the count, though at error it still fails a run at the default threshold. A todo a duplicate-test-name finding names is not counted either.
  • A test registered inside a loop is one case per iteration when the loop iterates an array literal or a let counter with integer literal bounds, directly or through .forEach or .map on an array literal. A const bound to an array literal counts the same when the file only iterates it, and each iteration runs after the declaration: later in the block or case that declares it, and not inside a function declaration that could be called earlier. The name has no other read, write or export, and the file has no eval and no code that may replace a built-in method. A counted loop over an empty array registers nothing: no case, suite or benchmark. A loop whose iterations the run cannot count, such as one over an array the file also changes or passes on, or one that can break, leaves its test uncompared, counts it once, and marks the run incomplete.
  • Every analyzed test is eligible except benchmarks, placeholders for the tests a wrapper call or module load registers, and test.todo with no callback. A .todo or .skip with a callback stays, and so does a test the run could not compare.
  • A test under an inline suppression is not counted as duplicated, even inside a finding that stays reported. Baselined findings leave the count of duplicated cases; their cases stay eligible. --changed-since keeps every eligible case.
  • With no eligible case there is no rate, and the threshold passes. At the default threshold of 0 any error-severity finding still fails the run.

Every report publishes the three figures: the terminal footer, qualityGate (errorCases, eligibleCases, percentage) in the json and jsonl summaries, HTML and SARIF run properties, and the Action’s error-cases, eligible-cases and duplication-percentage outputs. Earlier releases divided location-level findings by every analyzed test, so a nonzero threshold set against them needs recalibrating.

Single * and ? wildcards stay within a path component; use ** to match across directories. This also applies to resolved Vitest project globs and project paths, and to the base revision --baseline-from-ref reads.

VitestDedup reads test.include, test.exclude, test.globals, project lists, and the typecheck channel from vitest.config.* and vite.config.* without executing them.

*.test.* and *.spec.* are recognized by default. A Vitest config that declares its own include replaces that list, so a project naming **/*.unit.ts gets exactly those files. An include written in .vitest-dedup.json is an instruction and is never widened by a project’s broader list.

Differences from the set Vitest runs:

  • The analyzer applies its own default exclude list when none is written: node_modules, dist, build, coverage, .idea, .git, .cache, .output and .temp. Vitest’s default excludes only node_modules and .git, so test files under build/ or coverage/ are not analyzed.
  • Hidden (dot-prefixed) directories are skipped.
  • includeSource is additive. A file matching it is also scanned for in-source tests, whether or not include matches it.

Optional extglob groups such as ?(spec|test) are expanded into at most 64 concrete patterns per glob. A larger expansion, including one whose count overflows, is refused and makes the project configuration incomplete. Simplify the pattern to stay within this limit.

A config declaring test.projects, or a vitest.workspace.* file, is resolved entry by entry, honouring extends: false.

Project discovery limits each glob to 16 KiB of UTF-8 text and shares a 1 MiB compilation-text budget across the project list, including directory-prefix matchers needed for symlink checks. Exceeding either limit stops resolution and reports an incomplete project map. Simplify the patterns or analyze a smaller project root; entries are never silently dropped.

Every path a configuration names must resolve inside the analyzed directory, after symlinks and .. segments are followed: project entries and globs, a project’s string extends, a mergeConfig base import, a project’s root or dir, and tsconfig paths. A path that leaves it is not read. The run reports which one and is incomplete: the entry is an unresolved project, or the tsconfig import is unresolved. Paths that stay inside are not refused, including .. that folds back and symlinks that point within the tree. A re-export hop followed only to read an imported constant in a .each table is the exception: its cell stays unresolved and nothing is reported, neither the refusal nor a missing package or tsconfig on that chain. The root’s own vitest.config.* or vitest.workspace.* is held to the same rule, so a symlink to a file outside the directory is refused. A refused extends or mergeConfig base is reported whatever the project sets for itself, and whether or not any test runs under it. Relative imports in test files are not configuration and may still reach outside. The import resolver may read a package.json under a tsconfig-mapped directory outside the tree to decide which file inside it an import resolves to, and follows a tsconfig references entry wherever it points.

A tsconfig extends target that does not exist (typically a generated file) or cannot be read, and a missing node_modules when imports of listed dependencies fail, make the run incomplete and are named with a fix; see Missing prerequisites. Nuxt projects without a user tsconfig can use their generated .nuxt configuration automatically; see Nuxt projects for discovery and project-boundary rules.

globals: true is detected from the resolved config. A project list built with glob.sync from the glob package is read when its pattern is a string literal and its only option is a literal ignore of plain relative ASCII patterns; an ignore pattern that is absolute or not ASCII, has a ., .. or empty segment, a trailing /, ** inside a segment or two ** segments in a row, a backslash, ?, !, (, ), :, [...], or a brace that is not a comma list leaves the list unresolved (an optional ?(...) group is expanded first). On macOS and Windows an ignore pattern matches regardless of case, as glob’s does there. A pattern can therefore select different projects on a developer’s macOS or Windows machine and on Linux CI; use consistent path casing for portable project lists. A project config file that only forwards another one (export { default } from './shared', or an import exported again as the default), with no other runtime imports, is read as that config, from the project’s own directory. Imported config literals may carry a simple TypeScript-only as/satisfies/non-null suffix. A supported mergeConfig call may pass through one local const before the default export when imports, that declaration and the export are the file’s only statements. When the project list is built in a way no static reader can follow, such as a bare variable or mergeConfig with a dynamic import, the setting is reported as undetermined and the flag is needed:

Terminal window
vitest-dedup . --globals

The flag is opt-in because ambient describe and it cannot be told apart from Cypress, Mocha, or Jasmine without project configuration, and guessing would invent findings in those files.

Vitest 3, 4 and 5 format parameterized titles differently (see Parameterized rows). Each test file’s major comes from the installed node_modules/vitest, else from the nearest package.json whose vitest range names one major, never from outside the analysis root. When neither names one, for example a pnpm catalog: or workspace: range, the vitestMajor key or --vitest-major supplies it (the flag wins):

Terminal window
vitest-dedup . --vitest-major 4

It accepts 3, 4 or 5 and applies only to files whose metadata names no major. Without it, such a title is proved only where every major renders it alike. --baseline-from-ref reads the base revision’s major from its committed metadata in the same order, never from the working tree.

When no executable tests are analyzed and no quality-gate failure applies, the command exits with operational-error code 2 instead of treating an empty report as clean. A real suite-level quality failure or too many new findings under --fail-on-new remains exit 1.

  • If test-shaped files were read but yielded no tests, the diagnostic reports that observation and suggests checking both test.globals (or --globals) and build-time transforms such as auto-imports. It does not claim either cause was proved.
  • Known cases, such as statically empty .each/.for tables, receive a more specific diagnostic.

Source size, nesting and work limits, and the memory budget, are on Incomplete runs and limits.

Back to the documentation index.