From d1a06730ec1bce40d7f71b4942808d193cae272f Mon Sep 17 00:00:00 2001 From: Han Date: Thu, 22 Feb 2024 20:27:25 +0800 Subject: [PATCH] fix: repeatable `--project` option (#5265) --- packages/vitest/src/node/cli/cli-config.ts | 1 + test/core/test/cli-test.test.ts | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/packages/vitest/src/node/cli/cli-config.ts b/packages/vitest/src/node/cli/cli-config.ts index aeefab1f4d6c..ce0c7120ef84 100644 --- a/packages/vitest/src/node/cli/cli-config.ts +++ b/packages/vitest/src/node/cli/cli-config.ts @@ -526,6 +526,7 @@ export const cliOptionsConfig: VitestCLIOptions = { project: { description: 'The name of the project to run if you are using Vitest workspace feature. This can be repeated for multiple projects: --project=1 --project=2', argument: '', + array: true, }, slowTestThreshold: { description: 'Threshold in milliseconds for a test to be considered slow (default: 300)', diff --git a/test/core/test/cli-test.test.ts b/test/core/test/cli-test.test.ts index a3addf3749e2..0cf5b61b3847 100644 --- a/test/core/test/cli-test.test.ts +++ b/test/core/test/cli-test.test.ts @@ -321,4 +321,13 @@ test('public parseCLI works correctly', () => { expect(() => { parseCLI('node --test --coverage --browser --typecheck') }).toThrowError(`Expected "vitest" as the first argument, received "node"`) + + expect(parseCLI('vitest --project=space_1 --project=space_2')).toEqual({ + filter: [], + options: { + 'project': ['space_1', 'space_2'], + '--': [], + 'color': true, + }, + }) })