Skip to content
VitestDedup

v0.11.0 · MIT · static analysis

Find duplicated tests.Reduce redundancy.Keep your test suite maintainable.

VitestDedup reads your Vitest test files — never importing or executing them — and reports duplicate and near-duplicate tests: identical bodies hiding under different titles, structural copies that differ only in literals, whole suites repeated across files.

Every command and output shown on this site comes from a real run of the CLI.

vitest-dedup
$ npx vitest-dedup .
VitestDedup v0.11.0

duplicate-test
  [error] 2 tests have identical bodies under an equivalent context
    --> tests/seeded/session.spec.ts:5:3  session > sends anonymous visitors to login
    related: tests/seeded/session.spec.ts:10:3  session > redirects when signed out
    action: Review whether to remove a redundant test or repair a test whose body misses its named behavior.

cross-file-duplicate
  [warning] 2 tests across 2 files have identical bodies under an equivalent context
    --> tests/seeded/login.spec.ts:5:3  login > redirects when signed out
    related: tests/seeded/session.spec.ts:5:3  session > sends anonymous visitors to login

parameterization-candidate
  [warning] 2 tests share identical structure but differ only in literal values; consolidate into one `test.each` table that keeps every case as its own row
    --> tests/seeded/users.spec.ts:5:3  users > lists admin users
    related: tests/seeded/users.spec.ts:9:3  users > lists guest users

Analyzed 1007 tests in 43 files: 1 error, 3 warnings, 0 off; 0 suppressed
Analysis policy: FAIL

Found 4 findings.
Detection time: 222.4 ms

Real output of vitest-dedup v0.11.0 on a generated 1,007-test project, abridged: two findings are left out

Test suites grow. Duplication compounds.

Copy-pasting a test and tweaking a value is the fastest way to add coverage today — and the slowest way to change anything tomorrow. As a suite grows, duplicated tests quietly pile up:

  • A refactor touches the same logic in three places, or none of them get updated.
  • Redundant cases keep executing on every run, inflating CI time.
  • Nobody can say which test is authoritative, so failures get skimmed instead of read.
  • Reviewing new tests gets harder because near-copies look intentional.

A test's identity is its body

The analyzer's core judgment, in two sentences:

Two tests that do the same thing under different titles are duplicates. Two textually identical bodies that run under different hooks, mocks, or fixtures are not.

That distinction is why VitestDedup is an analysis tool rather than an auto-fixer. It names what each finding claims — a verdict with a remedy— and the decision to consolidate stays with you.

Features

Everything the analyzer actually does

No invented capabilities — each of these is shipped behavior ofv0.11.0, documented in thereference.

Reports

What a run tells you

Every finding carries a rule, a severity, a verdict, stable fingerprints, and full participant locations — the fields the json andsarif reporters write for machines.

tests analyzed
1,007
files analyzed
43
findings
4
detection time
222.1 ms
redundanttests/seeded/session.spec.ts ↔ session.spec.tserror

rule duplicate-test · fingerprintvitestDedupFingerprint/v1:bc7c1030e573af9e

2 tests have identical bodies under an equivalent context.

  • tests/seeded/session.spec.ts:5:3“session > sends anonymous visitors to login”
  • tests/seeded/session.spec.ts:10:3“session > redirects when signed out”

Action: Review whether to remove a redundant test or repair a test whose body misses its named behavior..

redundanttests/seeded/login.spec.ts ↔ session.spec.tswarning

rule cross-file-duplicate · fingerprintvitestDedupFingerprint/v1:28dbded76b424077

2 tests across 2 files have identical bodies under an equivalent context.

  • tests/seeded/login.spec.ts:5:3“login > redirects when signed out”
  • tests/seeded/session.spec.ts:5:3“session > sends anonymous visitors to login”

Action: Review whether duplication across files is intentional before consolidating or removing a copy..

consolidatabletests/seeded/users.spec.ts ↔ users.spec.tswarning

rule parameterization-candidate · fingerprintvitestDedupFingerprint/v1:a44398758b1eef28

2 tests share identical structure but differ only in literal values; consolidate into one `test.each` table that keeps every case as its own row.

  • tests/seeded/users.spec.ts:5:3“users > lists admin users”
  • tests/seeded/users.spec.ts:9:3“users > lists guest users”

Action: Consolidate into a parameterized table while preserving every case and assertion..

consolidatabletests/shipping/shipping28.spec.ts ↔ shipping28.spec.tswarning

rule parameterization-candidate · fingerprintvitestDedupFingerprint/v1:d8b6302825ddd7cc

2 tests share identical structure but differ only in literal values; consolidate into one `test.each` table that keeps every case as its own row.

  • tests/shipping/shipping28.spec.ts:66:3“shipping28 > normalizes invoice case 8”
  • tests/shipping/shipping28.spec.ts:86:3“shipping28 > merges profile case 11”

Action: Consolidate into a parameterized table while preserving every case and assertion..

Real output of vitest-dedup 0.6.0 on a generated 1007-test project (demo/generate-sample-project.mjs), reshaped for display. Structured to consume real --reporters json output later without changing these components.

Workflow

From first run to a gate you can trust

  1. 1

    Install

    A prebuilt binary for your platform arrives through optionalDependencies — no postinstall script, nothing compiled or executed at install time.

    npm install --save-dev vitest-dedup
  2. 2

    Analyze

    Discovery reads your Vitest configuration statically, then every test file is parsed and compared. Nothing is imported or run.

    npx vitest-dedup .
  3. 3

    Triage

    Each finding carries a verdict and an action. Deliberate parallels get a vitest-dedup-disable-next-line comment right in the test.

    vitest-dedup . --reporters html
  4. 4

    Gate

    Record existing debt once, then fail only for what new work adds. In CI, the GitHub Action verifies the binary before running it.

    vitest-dedup . --baseline dedup-baseline.json