oxc-project/oxc · error · OxcDiagnostic

Test has no assertions

Error message

Test has no assertions

What it means

Emitted by run of the expect-expect jest/vitest rule when a test callback body contains no assertion call (no expect(...) usage, per the configured assertFunctionMatcher). It is a completeness guard catching tests that pass trivially because they never verify anything.

Source

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

    ast::{CallExpression, Expression, FormalParameter, Function, Statement},
};
use oxc_ast_visit::{VisitJs, walk_js};
use oxc_diagnostics::OxcDiagnostic;
use oxc_span::{GetSpan, Span};
use oxc_str::CompactStr;
use oxc_syntax::scope::ScopeFlags;

use crate::{
    ast_util::get_declaration_of_variable,
    context::LintContext,
    utils::{
        JestFnKind, JestGeneralFnKind, PossibleJestNode, convert_pattern, get_node_name,
        is_type_of_jest_fn_call,
    },
};

fn expect_expect_diagnostic(span: Span) -> OxcDiagnostic {
    OxcDiagnostic::warn("Test has no assertions")
        .with_help("Add assertion(s) in this Test")
        .with_label(span)
}

pub const SHORT_DESCRIPTION: &str = "Enforce that each test has at least one `expect()` call.";

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

This rule triggers when there is no call made to `expect` in a test, ensure that there is at least one `expect` call made in a test.

### Why is this bad?

People may forget to add assertions.

### Examples

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

View on GitHub (pinned to a3d33dda7c)

Solutions

  1. Add at least one expect() assertion inside the test body
  2. If the test intentionally has no assertions, configure the rule's assertFunctionMatcher or disable it for that test
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at crates/oxc_linter/src/rules/shared/jest_vitest/expect_expect.rs:26 when the library encounters an invalid state.

Common situations: See trigger scenarios.


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