From 751c3926fc13a1a1d85e8e47a6903f87dc3b60fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ari=20Perkki=C3=B6?= Date: Mon, 3 Nov 2025 22:19:11 +0200 Subject: [PATCH] fix(cli): parse `--execArgv` as array (#8924) --- docs/config/index.md | 5 +++++ packages/vitest/src/node/cli/cli-config.ts | 1 + test/core/test/cli-test.test.ts | 10 ++++++++++ 3 files changed, 16 insertions(+) diff --git a/docs/config/index.md b/docs/config/index.md index a2043a15b..01164d4cc 100644 --- a/docs/config/index.md +++ b/docs/config/index.md @@ -724,9 +724,14 @@ Similar as `vmThreads` pool but uses `child_process` instead of `worker_threads` - **Type:** `string[]` - **Default:** `[]` +- **CLI:** `--execArgv= --execArgv=` Pass additional arguments to `node` in the runner worker. See [Command-line API | Node.js](https://nodejs.org/docs/latest/api/cli.html) for more information. +```sh +vitest --execArgv=--cpu-prof --execArgv=--cpu-prof-dir=./cpu-profile +``` + :::warning Be careful when using, it as some options may crash worker, e.g. --prof, --title. See https://github.com/nodejs/node/issues/41103. ::: diff --git a/packages/vitest/src/node/cli/cli-config.ts b/packages/vitest/src/node/cli/cli-config.ts index d72ff4508..9e75938b8 100644 --- a/packages/vitest/src/node/cli/cli-config.ts +++ b/packages/vitest/src/node/cli/cli-config.ts @@ -408,6 +408,7 @@ export const cliOptionsConfig: VitestCLIOptions = { execArgv: { description: 'Pass additional arguments to `node` process when spawning `worker_threads` or `child_process`.', argument: '