oxc-project/oxc · error

Describe requires name and callback arguments

Error message

Describe requires name and callback arguments

What it means

Diagnostic from the oxlint `jest/valid-describe-callback` rule (source: crates/oxc_linter/src/rules/shared/jest_vitest/valid_describe_callback.rs:18). This variant ('Describe requires name and callback arguments') fires when a `describe()` call has fewer than two arguments - missing the title or the callback. Jest would misbehave or error at runtime, so this rule catches the mistake at lint time.

Source

Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/valid_describe_callback.rs:18

use oxc_ast::{
    AstKind,
    ast::{Argument, Expression, FunctionBody, Statement},
};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::{GetSpan, Span};

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

fn valid_describe_callback_diagnostic(
    x1: &'static str,
    x2: &'static str,
    span3: Span,
) -> OxcDiagnostic {
    OxcDiagnostic::warn(x1).with_help(x2).with_label(span3)
}

#[derive(Clone, Copy)]
pub struct ValidDescribeCallbackOptions {
    allow_async_describe_callback: bool,
    allow_describe_options_argument: bool,
}

impl ValidDescribeCallbackOptions {
    pub const JEST: Self =
        Self { allow_async_describe_callback: false, allow_describe_options_argument: false };

    pub const VITEST: Self =
        Self { allow_async_describe_callback: true, allow_describe_options_argument: true };
}

pub fn run<'a>(
    possible_jest_node: &PossibleJestNode<'a, '_>,

View on GitHub (pinned to e1e7af627c)

Solutions

  1. Give describe both arguments: a string title and a function callback, e.g. `describe('feature', () => { /* tests */ })`.
  2. Delete the fragment if it is leftover scaffolding.
  3. If a custom wrapper around describe is being flagged, rename it or configure the framework's globals so the rule can tell them apart.

Example fix

// before
describe('user service');

// after
describe('user service', () => {
  test('loads a user', () => { /* ... */ });
});
Defensive patterns

Strategy: validation

Validate before calling

// rg -nU "describe\(\'[^\']*\'\)" tests/  # describe with no callback
// rg -n "describe\(\(\)" tests/

Prevention

When it happens

Trigger: `describe('title')`, `describe(() => {})`, or `describe()` - any describe call where either the name argument or the callback argument is absent (the source checks argument count before types).

Common situations: Incomplete scaffolding left in a spec file; merge artifacts that drop a callback; auto-generated tests from scripts that emit malformed describes; typos during refactors.

Related errors


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