Quick Start
Run the analyzer
Section titled “Run the analyzer”From your project root:
npx vitest-dedup .Discovery reads your Vitest configuration statically — test.include, test.exclude, test.globals,
project lists, and the typecheck channel — then every matched test file is parsed and compared.
Nothing is imported or executed.
vitest-dedup check <path> is the explicit form of vitest-dedup <path>.
Read the output
Section titled “Read the output”The terminal report groups findings by rule. Each finding shows its severity and message, a -->
primary location and related: locations, and a rule-specific action: line naming the remedy. The
footer summarizes analyzed tests and files, severities, inline suppressions, and the error-level
duplication threshold.
With the default threshold of 0, any error-severity finding fails the run — see exit codes.
Act on findings
Section titled “Act on findings”The remedy depends on the verdict:
- Redundant — one copy can go. Review removal, or repair the coverage one of the copies was supposed to provide.
- Consolidatable — every case is needed; they belong in one
test.eachtable. Deleting a row would lose coverage. - Name collision — rename one of the tests.
- Similar, review decides — the tests look equivalent without establishing that either adds no coverage. Review, and if they are the same behavior, consolidate.
A finding that is not debt — a deliberately parallel pair, for example — can be answered next to the code instead of in a baseline file:
// vitest-dedup-disable-next-line these two are deliberately parallel examplestest('adds numbers', () => { expect(add(1, 1)).toBe(2);});Every report states how many findings were suppressed this way.
Adopting on an existing codebase
Section titled “Adopting on an existing codebase”A codebase with existing duplication cannot turn the gate on at once. Record what is there, then gate on what is added:
vitest-dedup . --baseline dedup-baseline.json --update-baseline # record today's findingsvitest-dedup . --baseline dedup-baseline.json # gate only on what is newSee CI Integration for the full adoption path.
Next steps
Section titled “Next steps”- Browse every flag in the CLI reference.
- Tune severities in configuration.
- Choose a report format for how you read results.