Jest:运营商和运营商之间的差异1

什么时候使用每个--runInBand或 – --maxWorkers 1选项是合适的?

如果我的意图是按顺序依次运行所有testing(按顺序一个一个地进行),那么哪个才是正确的select?


额外的细节:

我正在使用Jesttesting一个NodeJs express应用程序,集成testing通过supertest敲击HTTP端点。 这可能对答案没有任何影响,只是在相关的情况下提及。

这里是Jest CLI参考:

https://facebook.github.io/jest/docs/cli.html

相关部分:

--maxWorkers=<num>

别名:-w。 指定工作池为运行testing而产生的最大工作者数量。 这默认为您的机器上可用的内核数量。 在CI等资源有限的环境中进行调整可能是有用的,但是对于大多数使用情况,默认值应该是足够的。

--runInBand

别名:-i。 在当前进程中连续运行所有testing,而不是创build运行testing的subprocess的工作池。 这对debugging很有用。

没有区别。 以下是从args对象读取的方法:

 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上的原始源代码