Skip to content

no-duplicate-test-case

Report repeated literal rows in framework each tables and Vitest for tables.

Why

Identical rows repeat the same inputs and expected values without exposing a distinct case. Accidental duplicates consume test time and hide a missing boundary vector.

Fix

Remove the accidental duplicate or replace it with the intended distinct boundary. Preserve intentional repeated or stateful scenarios with a local explanation; do not delete their coverage automatically.

Examples

Before — flagged A copied row misses the intended boundary
src/format.test.ts
import { it } from "vitest";
it.each([
[0, "0ms"],
[0, "0ms"],
])("%s", (input, expected) => {
expect(format(input)).toBe(expected);
});
After — preferred Distinct inputs have independent rows
src/format.test.ts
import { it } from "vitest";
it.each([
[0, "0ms"],
[1, "1ms"],
])("%s", (input, expected) => {
expect(format(input)).toBe(expected);
});
Before — flagged Vitest for tables retain the same case identity
src/format.test.ts
import { test } from "vitest";
test.for([
{ input: 0, expected: "0ms" },
{ input: 0, expected: "0ms" },
])("$input", ({ input, expected }) => {
expect(format(input)).toBe(expected);
});
After — preferred Vitest for tables preserve distinct boundaries
src/format.test.ts
import { test } from "vitest";
test.for([
{ input: 0, expected: "0ms" },
{ input: 1, expected: "1ms" },
])("$input", ({ input, expected }) => {
expect(format(input)).toBe(expected);
});
Before — flagged Fixture reuse preserves the literal case check
src/format.test.ts
import { test as base } from "vitest";
const test = base.extend({ locale: "en" });
test.for([1, 1])("formats %s", (value, { locale }) => {
expect(format(value, locale)).toBe("1");
});
After — preferred Fixture reuse preserves distinct independent cases
src/format.test.ts
import { test as base } from "vitest";
const test = base.extend({ locale: "en" });
test.for([1, 2])("formats %s", (value, { locale }) => {
expect(format(value, locale)).toBe(String(value));
});