gpt4 book ai didi

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

转载 作者:IT老高 更新时间:2023-10-28 23:10:30 26 4
gpt4 key购买 nike

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

如果我的意图是按顺序运行所有测试(一次一个,按顺序),那么哪个是正确的选择?


额外细节:

我正在使用 Jest 测试 NodeJs express应用程序,集成测试通过 supertest 访问 HTTP 端点.这可能对答案没有任何影响,只是在相关的情况下提及。

这是 Jest CLI 引用:

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

相关部分:

--maxWorkers=<num>

别名:-w。指定工作池为运行测试生成的最大工作人员数。这默认为您机器上可用的内核数。在 CI 等资源有限的环境中调整此设置可能很有用,但默认值对于大多数用例来说应该足够了。

--runInBand

别名:-i。在当前进程中连续运行所有测试,而不是创建运行测试的子进程的工作池。这对于调试很有用。

最佳答案

没有区别。这是从 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);
}
}

original source code on github

关于javascript - 开 Jest : Difference betwen --runInBand and --maxWorkers 1,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42637024/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com