oxc-project/oxc · warning · OxcDiagnostic

Test title is used multiple times in the same describe block

Error message

Test title is used multiple times in the same describe block.

What it means

The test variant of oxlint rule `jest/no-identical-title` (shared with vitest), the test_repeat constructor at crates/oxc_linter/src/rules/shared/jest_vitest/no_identical_title.rs:27. Two test cases (it/test) at the same describe level must not share a title, because identical names make failures in the report ambiguous. Sibling uniqueness, not global uniqueness, is what is checked.

Source

Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/no_identical_title.rs:26

use rustc_hash::FxHashMap;

use crate::{
    AstNode,
    context::LintContext,
    utils::{
        JestFnKind, JestGeneralFnKind, PossibleJestNode, collect_possible_jest_call_node,
        parse_general_jest_fn_call,
    },
};

fn describe_repeat(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Describe block title is used multiple times in the same describe block.")
        .with_help("Change the title of describe block.")
        .with_label(span)
}

fn test_repeat(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Test title is used multiple times in the same describe block.")
        .with_help("Change the title of test.")
        .with_label(span)
}

pub const DOCUMENTATION: &str = r"### What it does

This rule looks at the title of every test and test suite.
It will report when two test suites or two test cases at the same level of a test suite have the same title.

### Why is this bad?

Having identical titles for two different tests or test suites may create confusion.
For example, when a test with the same title as another test in the same test suite fails, it is harder to know which one failed and thus harder to fix.

### Examples

Examples of **incorrect** code for this rule:
```javascript

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Rename the later test to describe the specific behavior it verifies
  2. When generating tests in a loop, interpolate the case into the title (it(`handles ${input}`))
  3. Delete one test if the duplicate is a true copy testing nothing new

Example fix

// before
it('saves the form', fn1);
it('saves the form', fn2);

// after
it('saves the form', fn1);
it('saves the form and notifies', fn2);
Defensive patterns

Strategy: validation

Validate before calling

npx oxlint -c .oxlintrc.json tests/ # jest/no-identical-title reports sibling tests sharing a title

Prevention

When it happens

Trigger: Two or more it()/test() calls with the same string-literal title under the same parent describe (e.g. two `it('works')` siblings). Titles in different describes may repeat freely; the duplicate sibling is reported at its span.

Common situations: Copy-paste tests with the name left unchanged; loops that generate tests with a constant title instead of interpolating the case; suites grown organically where names drifted into collisions; reporters that then show indistinguishable failure entries.

Related errors


AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20). Data as JSON: /api/errors/5b21eea9801ae892. Report an issue: GitHub.