{"record":{"id":"a9033054a5cf22f1","repo":"oxc-project/oxc","slug":"expect-member-name-must-be-awaited-or-returned-a90330","errorCode":null,"errorMessage":"`expect.{member_name}` must be awaited or returned as the last expression","messagePattern":"`expect\\.(.+?)` must be awaited or returned as the last expression","errorType":"validation","errorClass":"OxcDiagnostic","httpStatus":null,"severity":"error","filePath":"crates/oxc_linter/src/rules/vitest/require_awaited_expect_poll.rs","lineNumber":22,"sourceCode":"use oxc_macros::declare_oxc_lint;\nuse oxc_span::Span;\n\nuse crate::{\n    AstNode,\n    context::LintContext,\n    rule::Rule,\n    rules::PossibleJestNode,\n    utils::{KnownMemberExpressionProperty, parse_expect_and_typeof_vitest_fn_call},\n};\n\nfn require_awaited_expect_poll_diagnostic(span: Span, member_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"`expect.{member_name}` must be awaited or returned\"))\n        .with_help(format!(\"Add `await` to the `expect.{member_name}` call.\"))\n        .with_label(span)\n}\n\nfn require_awaited_expect_poll_return_diagnostic(span: Span, member_name: &str) -> OxcDiagnostic {\n    OxcDiagnostic::warn(format!(\"`expect.{member_name}` must be awaited or returned as the last expression\"))\n          .with_help(format!(\"Add `await` to the `expect.{member_name}` call or move it to the last position in the sequence.\"))\n          .with_label(span)\n}\n\n#[derive(Debug, Default, Clone)]\npub struct RequireAwaitedExpectPoll;\n\ndeclare_oxc_lint!(\n    /// ### What it does\n    ///\n    /// This rule ensures that promises returned by `expect.poll` and `expect.element` calls are handled properly.\n    ///\n    /// ### Why is this bad?\n    ///\n    /// `expect.poll` and `expect.element` return promises. If not awaited or returned,\n    /// the test completes before the assertion resolves, meaning the test will pass\n    /// regardless of whether the assertion succeeds or fails.\n    ///","sourceCodeStart":4,"sourceCodeEnd":40,"githubUrl":"https://github.com/oxc-project/oxc/blob/e1e7af627c8843ab64044ed466b128fcc21a035b/crates/oxc_linter/src/rules/vitest/require_awaited_expect_poll.rs#L4-L40","documentation":"Emitted by the vitest/require-awaited-expect-poll rule when a poll-based expectation is awaited/returned but is not the last expression of its block, so the test continues after the poll completes. The rule requires poll assertions to be final so no assertions execute after an await that may skip them.","triggerScenarios":"Thrown at crates/oxc_linter/src/rules/vitest/require_awaited_expect_poll.rs:22 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Move the awaited `expect.poll()` assertion to be the last statement of the test/callback body"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"e1e7af627c8843ab64044ed466b128fcc21a035b","analyzedAt":"2026-08-20T07:01:07.079Z","contentChangedAt":"2026-08-20T07:01:07.079Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}