mirror of
https://github.com/vitest-dev/vitest.git
synced 2026-02-01 17:36:51 +00:00
docs: update .each information
This commit is contained in:
parent
f789776546
commit
6b977f2dcf
@ -196,6 +196,7 @@ You cannot use this syntax, when using Vitest as [type checker](/guide/testing-t
|
||||
:::
|
||||
|
||||
### test.each
|
||||
- **Version:** `v0.25.3`
|
||||
- **Type:** `(cases: ReadonlyArray<T>, ...args: any[]) => void`
|
||||
- **Alias:** `it.each`
|
||||
|
||||
@ -564,6 +565,7 @@ You cannot use this syntax, when using Vitest as [type checker](/guide/testing-t
|
||||
|
||||
### describe.each
|
||||
|
||||
- **Version:** `v0.25.3`
|
||||
- **Type:** `(cases: ReadonlyArray<T>, ...args: any[]): (name: string, fn: (...args: T[]) => void, options?: number | TestOptions) => void`
|
||||
|
||||
Use `describe.each` if you have more than one test that depends on the same data.
|
||||
|
||||
@ -77,31 +77,6 @@ Also, Vitest has `Args` type as a first argument instead of `Returns`, as you ca
|
||||
|
||||
Vitest doesn't support Jest's legacy timers.
|
||||
|
||||
**it.each**
|
||||
|
||||
Vitest intentionally doesn't support template literals for `it.each`. You will need to rewrite it to either an array of arguments, or array of objects:
|
||||
|
||||
Before:
|
||||
```ts
|
||||
it.each`
|
||||
a | b | expected
|
||||
${1} | ${3} | ${4}
|
||||
${2} | ${2} | ${4}
|
||||
`('adds $a to $b', ({ a, b, expected }) => {
|
||||
expect(add(a, b)).toEqual(expected)
|
||||
})
|
||||
```
|
||||
|
||||
After:
|
||||
```ts
|
||||
it.each([
|
||||
[1, 3, 4],
|
||||
[2, 2, 4],
|
||||
])('adds %d to %d', (a, b, expected) => {
|
||||
expect(add(a, b)).toEqual(expected)
|
||||
})
|
||||
```
|
||||
|
||||
**Vue Snapshots**
|
||||
|
||||
This is not a Jest-specific feature, but if you previously were using Jest with vue-cli preset, you will need to install [`jest-serializer-vue`](https://github.com/eddyerburgh/jest-serializer-vue) package, and use it inside [setupFiles](/config/#setupfiles):
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user