Jest: Difference betwen --runInBand and --maxWorkers 1

When is it appropriate to use each of the --runInBand or --maxWorkers 1 options?

If I intend to run all the tests sequentially (in turn, in order), which one is the right option?


Additional Information:

I use Jest to test the NodeJs express application, with integration tests hitting HTTP endpoints through supertest . This may not make any difference to the answer, just mentioning in case it matters.

Here is the Jest CLI link:

https://facebook.imtqy.com/jest/docs/cli.html

Relevant Parts:

--maxWorkers=<num>

Alias: -w. Specifies the maximum number of workers on which the work pool will be launched to run the tests. By default, this is the number of cores available on your computer. It may be useful to configure this in resource-limited environments such as CI, but the default should be sufficient for most use cases.

--runInBand

Alias: -i. Run all tests sequentially in the current process, and do not create a working pool of child processes that run tests. This can be useful for debugging.

+6
source share
1 answer

There is no difference. Here is the method in which it is read from the args object:

 export default function getMaxWorkers(argv: Argv): number { if (argv.runInBand) { return 1; } else if (argv.maxWorkers) { return parseInt(argv.maxWorkers, 10); } else { const cpus = os.cpus().length; return Math.max(argv.watch ? Math.floor(cpus / 2) : cpus - 1, 1); } } 

github source code

+3
source

Source: https://habr.com/ru/post/1015543/


All Articles