Skip to content

Commit

Permalink
docs: add information to the workspace docs on how to use extends (#6169
Browse files Browse the repository at this point in the history
)

Co-authored-by: Vladimir <sleuths.slews0s@icloud.com>
  • Loading branch information
CoolGoose and sheremet-va authored Jul 23, 2024
1 parent 93882f3 commit 17a81f0
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion docs/guide/workspace.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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
Expand Down

0 comments on commit 17a81f0

Please sign in to comment.