为何未使用--runInBand标志时Jest测试会失败?
问题描述
当不使用--runInBand标志或设置maxWorkers大于1时,测试会失败;但使用该标志或调整maxWorkers后,所有测试均可通过。示例代码托管在CodeSandbox。
失败场景复现步骤
- 执行命令:
npx jest --clearCache - 执行命令:
npx jest
执行结果:
成功场景复现步骤
- 执行命令:
npx jest --clearCache - 执行命令:
npx jest --runInBand
执行结果:
期望
无论是否使用--runInBand标志或设置maxWorkers参数,所有测试都能正常通过。
内容的提问来源于stack exchange,提问作者Michał Grenda
相关产品推荐
相关产品推荐

