oxc-project/oxc · warning

Enforce lowercase test names

Error message

Enforce lowercase test names

What it means

This is the oxlint `prefer-lowercase-title` rule (jest/vitest plugin). It enforces that the first letter of `it`/`test`/`describe`/`bench` titles is lowercase, which keeps generated failure sentences grammatical ('adds two numbers' vs 'Adds two numbers'). The diagnostic includes the offending title and points at the title argument span.

Source

Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/prefer_lowercase_title.rs:17

use oxc_ast::{AstKind, ast::Argument};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::Span;
use oxc_str::CompactStr;
use schemars::JsonSchema;
use serde::Deserialize;

use crate::{
    context::LintContext,
    rule::DefaultRuleConfig,
    utils::{
        JestFnKind, JestGeneralFnKind, ParsedJestFnCallNew, PossibleJestNode, parse_jest_fn_call,
    },
};

fn prefer_lowercase_title_diagnostic(title: &str, span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Enforce lowercase test names")
        .with_help(format!("`{title:?}`s should begin with lowercase"))
        .with_label(span)
}

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

Enforce `it`, `test`, `describe`, and `bench` to have descriptions that begin with a
lowercase letter. This provides more readable test failures.

### Why is this bad?

Lowercase messages for test failures generally result in more grammatically correct
failure messages when you have a test failure.

### Examples

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

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Lowercase the first letter of the title: `it('returns 404', ...)`.
  2. For titles that must start with a proper noun/acronym (e.g. 'HTTP ...'), add it to the rule's allowed prefixes option.
  3. If your team standard is capitalized titles, turn this rule off in .oxlintrc.json rather than fighting it file by file.

Example fix

// before
describe('UserApi', () => {
  it('Returns 404 for missing user', () => { /* ... */ });
});

// after
describe('userApi', () => {
  it('returns 404 for missing user', () => { /* ... */ });
});
Defensive patterns

Strategy: validation

Validate before calling

// .oxlintrc.json
{
  "rules": {
    "jest/prefer-lowercase-title": ["error", { "allowedPrefixes": ["HTTP", "GET", "POST"] }]
  }
}

npx oxlint tests/

Prevention

When it happens

Trigger: A title string literal passed to a test/describe/bench call whose first alphabetic character is uppercase — e.g. `it('Returns 404', ...)` — and not exempted by the rule's configuration.

Common situations: Teams writing titles as short sentences with a capital first word; porting tests from frameworks that capitalize titles; mixing conventions after a merge. Config knobs (allowedPrefixes, ignore, ignoreTopLevelDescribe in the ESLint original / schema-driven options here) let teams carve out exceptions.

Related errors


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