Soft Assertions, Polling & Assertion Counts in Vitest

From the Vitest cheat sheet · Assertions · verified Nov 2026

Soft Assertions, Polling & Assertion Counts

Keep going after a failure, retry until a value settles, and require assertions to run

typescript
expect.soft(res.status).toBe(200)        // keep going after a failure
expect.soft(res.body).toEqual({ ok: true })

await expect.poll(() => queue.size()).toBe(0)   // retry until it passes

expect.assertions(2)    // exactly 2 assertions must run
expect.hasAssertions()  // at least 1
📌 v5: expect.poll fails on timeout; its callback gets an AbortSignal
⚠️ Always await expect.poll; it returns a promise
💡 expect.unreachable() and expect.fail() flag code that should not run
🎯 expect.requireAssertions catches tests that never assert
softpollassertions

Continue with Vitest

Save the full cheat sheet or work through every related task.

More Vitest tasks

Back to the full Vitest cheat sheet