diff --git a/docs/guide/cli.md b/docs/guide/cli.md index 76b7fabb74da..ab9cec5a4fc3 100644 --- a/docs/guide/cli.md +++ b/docs/guide/cli.md @@ -74,8 +74,8 @@ Run only [benchmark](https://vitest.dev/guide/features.html#benchmarking-experim | `--poolOptions.threads.isolate` | Isolate tests in threads pool (default: `true`) | | `--poolOptions.forks.isolate` | Isolate tests in forks pool (default: `true`) | | `--fileParallelism` | Should all test files run in parallel. Use --no-file-parallelism to disable (default: true) | -| `--maxWorkers` | Maximum number of workers to run tests in | -| `--minWorkers` | Minimum number of workers to run tests in | +| `--maxWorkers ` | Maximum number of workers to run tests in | +| `--minWorkers ` | Minimum number of workers to run tests in | | `--silent` | Silent console output from tests | | `--reporter ` | Select reporter: `default`, `verbose`, `dot`, `junit`, `json`, or a path to a custom reporter | | `--outputFile ` | Write test results to a file when the `--reporter=json` or `--reporter=junit` option is also specified
Via [cac's dot notation] you can specify individual outputs for multiple reporters | diff --git a/packages/vitest/src/node/cli.ts b/packages/vitest/src/node/cli.ts index 77734459a400..7504532ea39d 100644 --- a/packages/vitest/src/node/cli.ts +++ b/packages/vitest/src/node/cli.ts @@ -39,8 +39,8 @@ cli .option('--poolOptions.threads.isolate', 'Isolate tests in threads pool (default: true)') .option('--poolOptions.forks.isolate', 'Isolate tests in forks pool (default: true)') .option('--fileParallelism', 'Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)') - .option('--maxWorkers', 'Maximum number of workers to run tests in') - .option('--minWorkers', 'Minimum number of workers to run tests in') + .option('--maxWorkers ', 'Maximum number of workers to run tests in') + .option('--minWorkers ', 'Minimum number of workers to run tests in') .option('--environment ', 'Specify runner environment, if not running in the browser (default: node)') .option('--passWithNoTests', 'Pass when no tests found') .option('--logHeapUsage', 'Show the size of heap for each test') diff --git a/packages/vitest/src/node/config.ts b/packages/vitest/src/node/config.ts index 74c4caea2c37..d319d61fb2d5 100644 --- a/packages/vitest/src/node/config.ts +++ b/packages/vitest/src/node/config.ts @@ -120,6 +120,12 @@ export function resolveConfig( resolved.shard = { index, count } } + if (resolved.maxWorkers) + resolved.maxWorkers = Number(resolved.maxWorkers) + + if (resolved.minWorkers) + resolved.minWorkers = Number(resolved.minWorkers) + resolved.fileParallelism ??= true if (!resolved.fileParallelism) {