Claude Opus 5.5

vitest-5-0-0-3-b

Claude Code's read-only tools, web search on, ludion sync off

Question

My test passed even though the async assertion was wrong because I didn't await it. Does Vitest catch that?

Answer key

A correct answer says
A test fails if an async assertion (such as expect(...).resolves) is not awaited.
The stale answer
An un-awaited async assertion only prints a warning.

Answer

Partly. For `.resolves`/`.rejects` and `expect.poll`, Vitest 3 prints a warning at the end of a test if the assertion isn't awaited. As far as I know, Vitest 4 goes further and fails the test. Check the docs for your version, because I haven't confirmed this against the current release.

Vitest can't catch other async mistakes on its own. For example, an `expect` inside a `.then()` callback or a promise you never return may never run at all. To guard against those:
- **`expect.assertions(n)` or `expect.hasAssertions()`**: these fail the test if the assertions you expected never ran.
- **Lint rules**: `vitest/valid-expect` with `alwaysAwait`, or `@typescript-eslint/no-floating-promises`, flag a missing `await` before you even run the tests.

Answering cost $0.06.

Grade

correct

The judge's reason: It says the newer Vitest fails the test on un-awaited async assertions, framing the warning as older Vitest 3 behavior, though it hedges on the claim.

The judge's log

Session log

What the agent wrote, the tools it called, and what they returned, from docs/bench/2026-10-11-done3/runs/B-project/vitest-5-0-0-3-b.jsonl. Thinking and the session's settings are left out. The raw log

  1. Agent

    Partly. For `.resolves`/`.rejects` and `expect.poll`, Vitest 3 prints a warning at the end of a test if the assertion isn't awaited. As far as I know, Vitest 4 goes further and fails the test. Check the docs for your version, because I haven't confirmed this against the current release.
    
    Vitest can't catch other async mistakes on its own. For example, an `expect` inside a `.then()` callback or a promise you never return may never run at all. To guard against those:
    - **`expect.assertions(n)` or `expect.hasAssertions()`**: these fail the test if the assertions you expected never ran.
    - **Lint rules**: `vitest/valid-expect` with `alwaysAwait`, or `@typescript-eslint/no-floating-promises`, flag a missing `await` before you even run the tests.