Support maxWorkers or runInBand when using 'projects'
Author: nonaraCreated Dec 9, 2020Updated Sep 12, 2026
Labels:rocket: Feature RequestStale
Bug Report
When defining multiple projects via the projects config option, where one project has maxWorkers set (ie. 1), that setting is not respected.
In the case of a mono-repo, assume we have two projects. One which runs parallel, and another which needs to be run sequentially. For this, the latter has the config setting maxWorkers: 1.
When we run jest from the base config, however, the latter runs in parallel, ignoring the maxWorkers: 1 setting.
To Reproduce
- Setup a mono-repo with two jest config files
- Set one to
maxWorkers: 1 - Add both config paths to base
projectsproperty - Run jest
Expected behavior / Proposal
I propose the following:
- Determine global max workers as:
- (If present)
maxWorkerssetting in base config - (Otherwise) Determine the maximum value specified for
maxWorkersfound in all projects config files
- (If present)
- Allow each project to use
- (If present) Its own
maxWorkers# of workers - (Otherwise) The global maximum # of workers
- (If present) Its own
Effectively, this ensures that maxWorkers behaviour matches that of running jest on an individual project.
envinfo
System:
OS: Windows 10 10.0.19041
CPU: (4) x64 Intel(R) Core(TM) i7-4510U CPU @ 2.00GHz
Binaries:
Node: 14.13.1 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD
npm: 6.14.4 - C:\Program Files\nodejs\npm.CMD
npmPackages:
jest: ^26.5.3 => 26.6.2
Source: jestjs/jest