#10936·Jest

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

  1. Setup a mono-repo with two jest config files
  2. Set one to maxWorkers: 1
  3. Add both config paths to base projects property
  4. Run jest

Expected behavior / Proposal

I propose the following:

  1. Determine global max workers as:
    • (If present) maxWorkers setting in base config
    • (Otherwise) Determine the maximum value specified for maxWorkers found in all projects config files
  2. Allow each project to use
    • (If present) Its own maxWorkers # of workers
    • (Otherwise) The global maximum # of workers

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