Skip to content

Commit 0e77e69

Browse files
authoredJan 10, 2024
fix(vitest): correctly parse --maxWorkers/--minWorkers (#4924)
1 parent 743795e commit 0e77e69

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed
 

‎docs/guide/cli.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ Run only [benchmark](https://vitest.dev/guide/features.html#benchmarking-experim
7474
| `--poolOptions.threads.isolate` | Isolate tests in threads pool (default: `true`) |
7575
| `--poolOptions.forks.isolate` | Isolate tests in forks pool (default: `true`) |
7676
| `--fileParallelism` | Should all test files run in parallel. Use --no-file-parallelism to disable (default: true) |
77-
| `--maxWorkers` | Maximum number of workers to run tests in |
78-
| `--minWorkers` | Minimum number of workers to run tests in |
77+
| `--maxWorkers <workers>` | Maximum number of workers to run tests in |
78+
| `--minWorkers <workers>` | Minimum number of workers to run tests in |
7979
| `--silent` | Silent console output from tests |
8080
| `--reporter <name>` | Select reporter: `default`, `verbose`, `dot`, `junit`, `json`, or a path to a custom reporter |
8181
| `--outputFile <filename/-s>` | Write test results to a file when the `--reporter=json` or `--reporter=junit` option is also specified <br /> Via [cac's dot notation] you can specify individual outputs for multiple reporters |

‎packages/vitest/src/node/cli.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,8 @@ cli
3939
.option('--poolOptions.threads.isolate', 'Isolate tests in threads pool (default: true)')
4040
.option('--poolOptions.forks.isolate', 'Isolate tests in forks pool (default: true)')
4141
.option('--fileParallelism', 'Should all test files run in parallel. Use --no-file-parallelism to disable (default: true)')
42-
.option('--maxWorkers', 'Maximum number of workers to run tests in')
43-
.option('--minWorkers', 'Minimum number of workers to run tests in')
42+
.option('--maxWorkers <workers>', 'Maximum number of workers to run tests in')
43+
.option('--minWorkers <workers>', 'Minimum number of workers to run tests in')
4444
.option('--environment <env>', 'Specify runner environment, if not running in the browser (default: node)')
4545
.option('--passWithNoTests', 'Pass when no tests found')
4646
.option('--logHeapUsage', 'Show the size of heap for each test')

‎packages/vitest/src/node/config.ts

+6
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,12 @@ export function resolveConfig(
120120
resolved.shard = { index, count }
121121
}
122122

123+
if (resolved.maxWorkers)
124+
resolved.maxWorkers = Number(resolved.maxWorkers)
125+
126+
if (resolved.minWorkers)
127+
resolved.minWorkers = Number(resolved.minWorkers)
128+
123129
resolved.fileParallelism ??= true
124130

125131
if (!resolved.fileParallelism) {

0 commit comments

Comments
 (0)
Please sign in to comment.