From 17a81f099bcde5b77cb4dfaf38382e61fac036fa Mon Sep 17 00:00:00 2001 From: Alexandru Bucur Date: Tue, 23 Jul 2024 09:43:55 +0200 Subject: [PATCH] docs: add information to the workspace docs on how to use extends (#6169) Co-authored-by: Vladimir --- docs/guide/workspace.md | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/docs/guide/workspace.md b/docs/guide/workspace.md index 70818b605..2e2156fbb 100644 --- a/docs/guide/workspace.md +++ b/docs/guide/workspace.md @@ -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 -- 2.51.2