···35353636## isOk
37373838-- **Type:** `<T>(value: T, message?: string) => void`
3838+- **Type:** `<T>(value: T, message?: string) => asserts value`
3939- **Alias** `ok`
40404141Assert that the given `value` is truthy.
···195195196196## isTrue
197197198198-- **Type:** `<T>(value: T, message?: string) => void`
198198+- **Type:** `<T>(value: T, message?: string) => asserts value is true`
199199200200Asserts that `value` is true.
201201···211211212212## isNotTrue
213213214214-- **Type:** `<T>(value: T, message?: string) => void`
214214+- **Type:** `<T>(value: T, message?: string) => asserts value is Exclude<T, true>`
215215216216Asserts that `value` is not true.
217217···227227228228## isFalse
229229230230-- **Type:** `<T>(value: T, message?: string) => void`
230230+- **Type:** `<T>(value: T, message?: string) => asserts value is false`
231231232232Asserts that `value` is false.
233233···243243244244## isNotFalse
245245246246-- **Type:** `<T>(value: T, message?: string) => void`
246246+- **Type:** `<T>(value: T, message?: string) => asserts value is Exclude<T, false>`
247247248248Asserts that `value` is not false.
249249···259259260260## isNull
261261262262-- **Type:** `<T>(value: T, message?: string) => void`
262262+- **Type:** `<T>(value: T, message?: string) => asserts value is null`
263263264264Asserts that `value` is null.
265265···275275276276## isNotNull
277277278278-- **Type:** `<T>(value: T, message?: string) => void`
278278+- **Type:** `<T>(value: T, message?: string) => asserts value is Exclude<T, null>`
279279280280Asserts that `value` is not null.
281281···323323324324## exists
325325326326-- **Type:** `<T>(value: T, message?: string) => void`
326326+- **Type:** `<T>(value: T, message?: string) => asserts value is NonNullable<T>`
327327328328Asserts that `value` is neither null nor undefined.
329329···339339340340## notExists
341341342342-- **Type:** `<T>(value: T, message?: string) => void`
342342+- **Type:** `<T>(value: T, message?: string) => asserts value is null | undefined`
343343344344Asserts that `value` is either null nor undefined.
345345···357357358358## isUndefined
359359360360-- **Type:** `<T>(value: T, message?: string) => void`
360360+- **Type:** `<T>(value: T, message?: string) => asserts value is undefined`
361361362362Asserts that `value` is undefined.
363363···373373374374## isDefined
375375376376-- **Type:** `<T>(value: T, message?: string) => void`
376376+- **Type:** `<T>(value: T, message?: string) => asserts value is Exclude<T, undefined>`
377377378378Asserts that `value` is not undefined.
379379···631631632632## instanceOf
633633634634-- **Type:** `<T>(value: T, constructor: Function, message?: string) => void`
634634+- **Type:** `<T>(value: T, constructor: Function, message?: string) => asserts value is T`
635635636636Asserts that `value` is an instance of `constructor`.
637637···656656657657## notInstanceOf
658658659659-- **Type:** `<T>(value: T, constructor: Function, message?: string) => void`
659659+- **Type:** `<T>(value: T, constructor: Function, message?: string) => asserts value is Exclude<T, U>`
660660661661Asserts that `value` is not an instance of `constructor`.
662662
+30
docs/api/expect.md
···3939`expect` has no effect on testing types, if the expression doesn't have a type error. If you want to use Vitest as [type checker](/guide/testing-types), use [`expectTypeOf`](/api/expect-typeof) or [`assertType`](/api/assert-type).
4040:::
41414242+## assert
4343+4444+- **Type:** `Chai.AssertStatic`
4545+4646+Vitest reexports chai's [`assert` API](https://www.chaijs.com/api/assert/) as `expect.assert` for convenience. You can see the supported methods on the [Assert API page](/api/assert).
4747+4848+This is especially useful if you need to narrow down the type, since `expect.to*` methods do not support that:
4949+5050+```ts
5151+interface Cat {
5252+ __type: 'Cat'
5353+ mew(): void
5454+}
5555+interface Dog {
5656+ __type: 'Dog'
5757+ bark(): void
5858+}
5959+type Animal = Cat | Dog
6060+6161+const animal: Animal = { __type: 'Dog', bark: () => {} }
6262+6363+expect.assert(animal.__type === 'Dog')
6464+// does not show a type error!
6565+expect(animal.bark()).toBeUndefined()
6666+```
6767+6868+::: tip
6969+Note that `expect.assert` also supports other type-narrowing methods (like `assert.isDefined`, `assert.exists` and so on).
7070+:::
7171+4272## soft
43734474- **Type:** `ExpectStatic & (actual: any) => Assertions`