Skip to content

Commit

Permalink
fix(vitest): correctly parse --maxWorkers/--minWorkers (#4924)
Browse files Browse the repository at this point in the history
  • Loading branch information
sheremet-va committed Jan 10, 2024
1 parent 743795e commit 0e77e69
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions docs/guide/cli.md
Expand Up @@ -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 <workers>` | Maximum number of workers to run tests in |
| `--minWorkers <workers>` | Minimum number of workers to run tests in |
| `--silent` | Silent console output from tests |
| `--reporter <name>` | Select reporter: `default`, `verbose`, `dot`, `junit`, `json`, or a path to a custom reporter |
| `--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 |
Expand Down
4 changes: 2 additions & 2 deletions packages/vitest/src/node/cli.ts
Expand Up @@ -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 <workers>', 'Maximum number of workers to run tests in')
.option('--minWorkers <workers>', 'Minimum number of workers to run tests in')
.option('--environment <env>', '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')
Expand Down
6 changes: 6 additions & 0 deletions packages/vitest/src/node/config.ts
Expand Up @@ -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) {
Expand Down

0 comments on commit 0e77e69

Please sign in to comment.