运行Jest测试并从特定目录中的所有文件收集覆盖率 [英] Run Jest test and collect coverage from all files in a specific directory
本文介绍了运行Jest测试并从特定目录中的所有文件收集覆盖率的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用以下代码在特定文件上运行Jest测试.
I am using the following code to run Jest test on specific file.
jest utils.spec.js --collectCoverageFrom=**/utils.js
如果我要测试整个目录,请使用
If i want to test whole directory i use
jest someDirectory --collectCoverageFrom=**/someDirectory
但是这里的代码覆盖范围无效,为什么呢?
But the code coverage does not work here why is so?
谢谢.
推荐答案
您需要添加此模式/**/*.js
,该模式与所有子目录中的所有文件匹配:
You need to add this pattern /**/*.js
, that match all the files in all sub directories:
jest someDirectory --collectCoverageFrom=**/someDirectory/**/*.js
这篇关于运行Jest测试并从特定目录中的所有文件收集覆盖率的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文