docs: add information to the workspace docs on how to use extends (#6169)

Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
This commit is contained in:
Alexandru Bucur 2024-07-23 09:43:55 +02:00 committed by GitHub
parent 93882f388e
commit 17a81f099b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -156,7 +156,7 @@ npm run test --project e2e --project unit
None of the configuration options are inherited from the root-level config file. You can create a shared config file and merge it with the project config yourself:
:::code-group
::: code-group
```ts [packages/a/vitest.config.ts]
import { defineProject, mergeConfig } from 'vitest/config'
import configShared from '../vitest.shared.js'
@ -172,6 +172,30 @@ export default mergeConfig(
```
:::
At the `defineWorkspace` level you can also use the `extends` option instead to inherit from your root-level config.
::: code-group
```ts [packages/a/vitest.config.ts]
import { defineWorkspace } from 'vitest/config'
export default defineWorkspace([
{
extends: './vitest.config.ts',
test: {
name: 'unit',
include: ['**/*.unit.test.ts'],
},
},
{
extends: './vitest.config.ts',
test: {
name: 'integration',
include: ['**/*.integration.test.ts'],
},
},
])
```
:::
Also, some of the configuration options are not allowed in a project config. Most notably:
- `coverage`: coverage is done for the whole workspace