Skip to content

Commit

Permalink
docs: update globalSetup docs to reduce verbosity, link to config ins…
Browse files Browse the repository at this point in the history
…tead of showing examples inline
  • Loading branch information
dominikg committed Jan 5, 2022
1 parent c4337fe commit d04f3a4
Showing 1 changed file with 3 additions and 25 deletions.
28 changes: 3 additions & 25 deletions docs/config/index.md
Expand Up @@ -240,34 +240,12 @@ Path to setup files
- **Type:** `string | string[]`

Path to global setup files, relative to project root
```js
{
globalSetup: './vitest-global-setup.js'
}
```

Files can either export named functions
```js
let server;
export async function setup() {
server = await startServer()
}
export async function teardown() {
await server.close()
}
```

or a setup function as default that returns the teardown
```js
export default async function() {
const server = await startServer()
return async() => {
await server.close()
}
}
```
A global setup file can either export named functions `setup` and `teardown` or a `default` function that returns a teardown function ([example](https://github.com/vitest-dev/vitest/blob/main/test/global-setup/vitest.config.ts)).

::: info
Multiple globalSetup files are possible. setup and teardown are executed sequentially with teardown in reverse order.
:::


### watchIgnore
Expand Down

0 comments on commit d04f3a4

Please sign in to comment.