是否可以在Jest中并行运行一个文件中的测试? [英] Are tests inside one file run in parallel in Jest?

查看:340
本文介绍了是否可以在Jest中并行运行一个文件中的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

文档中的笑话状态: "Jest虚拟化JavaScript环境并跨工作进程并行运行测试."

Jest states in docs: "Jest virtualizes JavaScript environments and runs tests in parallel across worker processes."

但是在一个文件中进行多个测试又是并行运行还是该语句仅适用于测试文件呢?我可以假设一个文件中的测试按外观顺序和顺序运行吗?

But what about multiple tests inside one file, do they run in parallel or this statement applies just to the test files? Can I assume that tests in one file run in order of appearance and in serial?

推荐答案

是的,您可以放心地假设单个文件中的测试将按照外观顺序运行.您可以通过在每个it块中放置一个console.log来证明这一点.

Yes, you can safely assume tests inside a single file will run in the order of appearance. You could prove this by putting a console.log in each it block.

可能值得一提的是,依靠执行顺序/外部状态通常是不明智的做法……而且您永远不会知道,Jest(或当前的底层测试运行者Jasmine)可能会决定以随机顺序运行它们在较新的版本中.

It's probably worth mentioning that it's generally bad practice to rely on the order of execution / external state...and you never know, Jest (or the current underlying test runner, Jasmine) may decide to run them in a random order in a newer version.

这篇关于是否可以在Jest中并行运行一个文件中的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆