From 532cc11b0c6f482dfde927c0ea25d62b0cb36706 Mon Sep 17 00:00:00 2001 From: Drew Powers <1369770+drwpow@users.noreply.github.com> Date: Mon, 9 Jan 2023 14:18:53 -0700 Subject: [PATCH] docs: add info to toThrowError (#2447) #2262 --- docs/api/index.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/api/index.md b/docs/api/index.md index d12531ec4c76..fa00357268d1 100644 --- a/docs/api/index.md +++ b/docs/api/index.md @@ -1181,6 +1181,8 @@ You cannot use this syntax, when using Vitest as [type checker](/guide/testing-t - **Type:** `(received: any) => Awaitable` +- **Alias:** `toThrow` + `toThrowError` asserts if a function throws an error when it is called. For example, if we want to test that `getFruitStock('pineapples')` throws, we could write: @@ -1216,6 +1218,10 @@ You cannot use this syntax, when using Vitest as [type checker](/guide/testing-t }) ``` + :::tip + To test async functions, use in combination with [rejects](#rejects). + ::: + ### toMatchSnapshot - **Type:** `(shape?: Partial | string, message?: string) => void`