简体   繁体   English

使用 Jest 获取测试运行时间

[英]Get tests running time with Jest

is there any way to know how long my tests take without doing it programmatically with Jest?有没有办法知道我的测试需要多长时间而不用 Jest 以编程方式进行?

To be clear, I know that if I add a variable to get the current time before each test and then log this when my test completes I'll get this information, but I want this automatically, maybe with some Jest configuration.明确地说,我知道如果我在每次测试之前添加一个变量来获取当前时间,然后在我的测试完成时记录这个信息,我会得到这个信息,但我想要这个自动,也许有一些 Jest 配置。

So, any help on this?那么,这有什么帮助吗?

You shouldn't need any configuration to get the running time for your tests您不需要任何配置即可获得测试的运行时间

PASS  src/containers/Dashboard/Dashboard.test.tsx (12.902s)

That 12.902s in the brackets is the running time for the test suite.括号中的 12.902s 是测试套件的运行时间。

If you want to see the running time per test you can run jest with the --verbose flag and it will show you the time for each test as well as the whole suite.如果您想查看每个测试的运行时间,您可以使用 --verbose 标志运行 jest,它会显示每个测试以及整个套件的时间。

  Dashboard Container
    ✓ render without crashing (1090ms)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM