docs: update .each information

This commit is contained in:
Vladimir Sheremet 2022-11-22 13:51:01 +01:00
parent f789776546
commit 6b977f2dcf
2 changed files with 2 additions and 25 deletions

View File

@ -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.

View File

@ -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):