question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support maxWorkers or runInBand when using 'projects'

See original GitHub issue

🐛 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

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:19
  • Comments:14

github_iconTop GitHub Comments

4reactions
fresholliecommented, Dec 15, 2021

@thymikee Is it possible someone could take a look at the PR for this? It may have been buried as it was first opened a year ago

4reactions
fresholliecommented, Oct 17, 2021

Finally updated my PR to implement this. Would be great to get a review 😃

Peek 2021-10-17 12-49

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest CLI Options
The jest command line runner has a number of useful options. You can run jest --help to view all available options. Many of...
Read more >
Jest: Difference betwen --runInBand and --maxWorkers 1
I'm using Jest to test a NodeJs express application, with integration tests hitting the HTTP endpoints via supertest . This may not make...
Read more >
Troubleshooting · Jest
Note: Debugging support with Jest only supports node debug ; it does yet ... statement in any of your tests, and then, in...
Read more >
How to make your sluggish Jest tests go faster - ITNEXT
Here's our original project's setup: React v16.5; Typescript v3.1; Jest v23.6 using jsdom as testEnvironment; ts-jest; Win10.
Read more >
Jest CLI Options - API Manual
Generate a basic configuration file. Based on your project, Jest will ask you a few questions that will help to generate a jest.config.js...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found