oxc-project/oxc · error · OxcDiagnostic
`expect.{member_name}` must be awaited or returned
Error message
`expect.{member_name}` must be awaited or returned What it means
Emitted by the vitest/require-awaited-expect-poll rule at an `expect.poll(...)` / `expect.element`-style call that is neither awaited nor returned from the test. Un-awaited poll assertions resolve asynchronously, so the test can finish before the assertion ever runs, silently passing without checking anything.
Source
Thrown at crates/oxc_linter/src/rules/vitest/require_awaited_expect_poll.rs:16
use oxc_allocator::GetAddress;
use oxc_ast::AstKind;
use oxc_diagnostics::OxcDiagnostic;
use oxc_macros::declare_oxc_lint;
use oxc_span::Span;
use crate::{
AstNode,
context::LintContext,
rule::Rule,
rules::PossibleJestNode,
utils::{KnownMemberExpressionProperty, parse_expect_and_typeof_vitest_fn_call},
};
fn require_awaited_expect_poll_diagnostic(span: Span, member_name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("`expect.{member_name}` must be awaited or returned"))
.with_help(format!("Add `await` to the `expect.{member_name}` call."))
.with_label(span)
}
fn require_awaited_expect_poll_return_diagnostic(span: Span, member_name: &str) -> OxcDiagnostic {
OxcDiagnostic::warn(format!("`expect.{member_name}` must be awaited or returned as the last expression"))
.with_help(format!("Add `await` to the `expect.{member_name}` call or move it to the last position in the sequence."))
.with_label(span)
}
#[derive(Debug, Default, Clone)]
pub struct RequireAwaitedExpectPoll;
declare_oxc_lint!(
/// ### What it does
///
/// This rule ensures that promises returned by `expect.poll` and `expect.element` calls are handled properly.
///View on GitHub (pinned to e1e7af627c)
Solutions
- Add `await` to the `expect.poll(...)` call
- Or return the assertion from the test callback so it is awaited by the runner
Defensive patterns
Strategy: validation
When it happens
Trigger: Thrown at crates/oxc_linter/src/rules/vitest/require_awaited_expect_poll.rs:16 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of oxc-project/oxc@e1e7af627c (2026-08-20).
Data as JSON: /api/errors/2ec95ea930389374.
Report an issue: GitHub.