oxc-project/oxc · warning
Should not have an empty title
Error message
Should not have an empty title
What it means
Diagnostic from the shared jest/vitest `valid-title` rule (empty_title_diagnostic). It fires when a test/describe block's title is an empty string. Empty titles make test reports unreadable and make it impossible to filter or select the test by name.
Source
Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/valid_title.rs:30
use oxc_span::{GetSpan, Span};
use oxc_str::CompactStr;
use crate::{
context::LintContext,
utils::{
JestFnKind, JestGeneralFnKind, PossibleJestNode, is_string_raw_member_expression,
parse_general_jest_fn_call,
},
};
fn title_must_be_string_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Title must be a string")
.with_help("Replace your title with a string")
.with_label(span)
}
fn empty_title_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Should not have an empty title")
.with_help("Write a meaningful title for your test")
.with_label(span)
}
fn duplicate_prefix_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Should not have duplicate prefix")
.with_help("The function name already has the prefix, try to remove the duplicate prefix")
.with_label(span)
}
fn accidental_space_diagnostic(span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn("Should not have leading or trailing spaces")
.with_help("Remove the leading or trailing spaces")
.with_label(span)
}
fn disallowed_word_diagnostic(word: &str, span: Span) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("{word} is not allowed in test title"))View on GitHub (pinned to e1e7af627c)
Solutions
- Write a meaningful title describing the expected behavior: `it('returns 404 for missing users', fn)`.
- If the block is scaffolding, remove it or `.skip` it with a TODO title.
- Add valid-title (or the no-empty-title checks) to CI so empty shells fail the build.
Example fix
// before
it('', () => {
expect(add(1, 2)).toBe(3);
});
// after
it('adds two numbers', () => {
expect(add(1, 2)).toBe(3);
}); Defensive patterns
Strategy: validation
Validate before calling
const emptyTitle = /\b(it|test|describe)(\.(skip|only|todo|concurrent|each))?\s*\(\s*(''|"")\s*,/;
if (emptyTitle.test(src)) { console.error('empty test title'); process.exitCode = 1; } Prevention
- Fill in the title before writing the body — an empty shell should never be committed.
- Use `.todo('planned behavior')` for unfinished tests instead of empty titles.
- Add a title linter to pre-commit hooks, not just CI.
When it happens
Trigger: A string-literal title with zero length: `it('', () => {})`, `describe('', () => {...})`, `test.skip('', fn)`.
Common situations: Template scaffolding where the placeholder title was never filled in; refactors that moved the description into a comment; copy-paste test shells committed by accident.
Related errors
- Title must be a string
- Should not have duplicate prefix
- Should not have leading or trailing spaces
- {word} is not allowed in test title
- {un_prefixed_name} should match {raw_pattern}
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/d66d78993e32195d.
Report an issue: GitHub.