mirror of
https://github.com/vitest-dev/vitest.git
synced 2025-12-08 18:26:03 +00:00
docs: clarify expect docs (#7853)
This commit is contained in:
parent
d97f6d4807
commit
ed9ee9d4ba
@ -6,7 +6,19 @@ The following types are used in the type signatures below
|
||||
type Awaitable<T> = T | PromiseLike<T>
|
||||
```
|
||||
|
||||
`expect` is used to create assertions. In this context `assertions` are functions that can be called to assert a statement. Vitest provides `chai` assertions by default and also `Jest` compatible assertions built on top of `chai`.
|
||||
`expect` is used to create assertions. In this context `assertions` are functions that can be called to assert a statement. Vitest provides `chai` assertions by default and also `Jest` compatible assertions built on top of `chai`. Unlike `Jest`, Vitest supports a message as the second argument - if the assertion fails, the error message will be equal to it.
|
||||
|
||||
```ts
|
||||
export interface ExpectStatic extends Chai.ExpectStatic, AsymmetricMatchersContaining {
|
||||
<T>(actual: T, message?: string): Assertion<T>
|
||||
extend: (expects: MatchersObject) => void
|
||||
anything: () => any
|
||||
any: (constructor: unknown) => any
|
||||
getState: () => MatcherState
|
||||
setState: (state: Partial<MatcherState>) => void
|
||||
not: AsymmetricMatchersContaining
|
||||
}
|
||||
```
|
||||
|
||||
For example, this code asserts that an `input` value is equal to `2`. If it's not, the assertion will throw an error, and the test will fail.
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user