docs: add two more feature to the announcement (#8073)

This commit is contained in:
Vladimir 2025-06-02 17:22:52 +02:00 committed by GitHub
parent c034a01267
commit 3d130c6f0b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 111 additions and 0 deletions

View File

@ -228,3 +228,100 @@ export default defineConfig({
},
})
```
## The New Multi-Purpose `Matchers` Type
Vitest now has a `Matchers` type that you can extend to add type support for all your custom matchers in one place. This type affects all these use cases:
- `expect().to*`
- `expect.to*`
- `expect.extend({ to* })`
For example, to have a type-safe `toBeFoo` matcher, you can write something like this:
```ts twoslash
import { expect } from 'vitest'
interface CustomMatchers<R = unknown> {
toBeFoo: (arg: string) => R
}
declare module 'vitest' {
interface Matchers<T = any> extends CustomMatchers<T> {}
}
expect.extend({
toBeFoo(actual, arg) {
// ^?
// ... implementation
return {
pass: true,
message: () => '',
}
}
})
expect('foo').toBeFoo('foo')
expect.toBeFoo('foo')
```
## `sequence.groupOrder`
The new [`sequence.groupOrder`](/config/#grouporder) option controls the order in which the project runs its tests when using multiple [projects](/guide/projects).
- Projects with the same group order number will run together, and groups are run from lowest to highest.
- If you dont set this option, all projects run in parallel.
- If several projects use the same group order, they will run at the same time.
::: details Example
Consider this example:
```ts
import { defineConfig } from 'vitest/config'
export default defineConfig({
test: {
projects: [
{
test: {
name: 'slow',
sequence: {
groupOrder: 0,
},
},
},
{
test: {
name: 'fast',
sequence: {
groupOrder: 0,
},
},
},
{
test: {
name: 'flaky',
sequence: {
groupOrder: 1,
},
},
},
],
},
})
```
Tests in these projects will run in this order:
```
0. slow |
|> running together
0. fast |
1. flaky |> runs after slow and fast alone
```
:::
----
The complete list of changes is at the [Vitest 3.2 Changelog](https://github.com/vitest-dev/vitest/releases/tag/v3.2.0).

View File

@ -845,6 +845,13 @@ Ignore type errors from source files
Path to a custom tsconfig file
### typecheck.spawnTimeout
- **CLI:** `--typecheck.spawnTimeout <time>`
- **Config:** [typecheck.spawnTimeout](/config/#typecheck-spawntimeout)
Minimum time in milliseconds it takes to spawn the typechecker
### project
- **CLI:** `--project <name>`
@ -908,6 +915,13 @@ Always print console stack traces
Collect test and suite locations in the `location` property
### attachmentsDir
- **CLI:** `--attachmentsDir <dir>`
- **Config:** [attachmentsDir](/config/#attachmentsdir)
The directory where attachments from `context.annotate` are stored in (default: `.vitest-attachments`)
### run
- **CLI:** `--run`