Skip to content
masterclass Buddy

Vitest · Module

rejects

expect(promise).rejects checks the reason for a rejected promise. Await the matcher because the assertion is asynchronous.

Last updated

Syntax

await expect(promise).rejects.toThrow(expected)

In-depth API docs are only for subscribers: parameters, examples, common mistakes and interview practice.

Subscribe
  • expect
  • resolves
  • toThrow
  • toThrowError
  • expect.assertions

Source: expect | Vitest. Checked 2026-11-03.