From 3fa7b78cbca652860be535c5632631e74556d4f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Mon, 14 Apr 2025 07:58:48 +0300 Subject: [PATCH] test: reduce max thread count when vitest-in-vitest (#7829) --- test/test-utils/index.ts | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/test/test-utils/index.ts b/test/test-utils/index.ts index 90e69feb8..d96cf9c37 100644 --- a/test/test-utils/index.ts +++ b/test/test-utils/index.ts @@ -83,6 +83,10 @@ export async function runVitest( NO_COLOR: 'true', ...rest.env, }, + + // Test cases are already run with multiple forks/threads + maxWorkers: 1, + minWorkers: 1, }, { ...viteOverrides, server: { @@ -147,7 +151,7 @@ interface CliOptions extends Partial { earlyReturn?: boolean } -export async function runCli(command: string, _options?: CliOptions | string, ...args: string[]) { +async function runCli(command: 'vitest' | 'vite-node', _options?: CliOptions | string, ...args: string[]) { let options = _options if (typeof _options === 'string') { @@ -155,6 +159,11 @@ export async function runCli(command: string, _options?: CliOptions | string, .. options = undefined } + if (command === 'vitest') { + args.push('--maxWorkers=1') + args.push('--minWorkers=1') + } + const subprocess = x(command, args, options as Options).process! const cli = new Cli({ stdin: subprocess.stdin!, -- 2.51.2