Jest comes pre-packaged with the ability to track code coverage for the modules you're testing, but it takes a little extra work to make it track untested files as well. Let's look at what Jest can do for you, what you have to do yourself, and how to setup code coverage thresholds so you can work to improving the code coverage numbers for your projects.

//package.json

{
...
"jest": {
"testEnvironment": "node",
"collectCoverageFrom": [
"src/*.js"
],
"coverageThreshold": {
"global": {
"branches": ,
"functions": ,
"lines": ,
"statements":
}
}
}
}

"collectCoverageFrom":  include all the js files, it will exclude *.test.js / *.spec.js files automatically

"coverageThreshold": limit the coverage, if below the coverage, it will report error

[Jest] Track project code coverage with Jest的更多相关文章

  1. [Webpack 2] Add Code Coverage to tests in a Webpack project

    How much of your code runs during unit testing is an extremely valuable metric to track. Utilizing c ...

  2. 【vue】在VS Code中调试Jest单元测试

    在VS Code中调试Jest单元测试 添加调试任务 打开 vscode launch.json 文件,在 configurations 内加入下面代码 "configurations&qu ...

  3. 10 Code Coverage Tools for C & C++

    Code coverage is a measure used in software testing that describes the degree to which the source co ...

  4. 测试工具 - IDEA - IDEA Code Coverage

    概述 使用 idea 自带的 code coverage 工具 背景 了解 白盒测试用例设计 和 测试覆盖率 之后, 大概就需要 实践 了 实践的话, 还是需要 工具 来检验效果 工具选取 选项 Ja ...

  5. [Jest] Write data driven tests in Jest with test.each

    Often, we end up creating multiple unit tests for the same unit of code to make sure it behaves as e ...

  6. Code Coverage and Unit Test in SonarQube

    概念 https://blog.ndepend.com/guide-code-coverage-tools/ Code Coverage Results Import (C#, VB.NET) Uni ...

  7. Gumshoe - Microsoft Code Coverage Test Toolset

    Gumshoe - Microsoft Code Coverage Test Toolset 2014-07-17 What is Gumshoe? How to instrument a binar ...

  8. Effective Java提升Code Coverage代码涵盖率 - 就是爱Java

    虽然我们已经有了测试程序,但是如何得知是否已完整测试了主程序?,透过Code Coverage代码涵盖率,我们可以快速地得知,目前系统中,有多少程序中被测试过,不考虑成本跟投资效益比,涵盖率越高,代表 ...

  9. CI集成phpunit Error: No code coverage driver is available 的解决

    CI集成phpunit时,运行报No code coverage driver is available的错误,如下图: yanglingdeMacBook-Pro:tests yangling$ p ...

随机推荐

  1. InnoDB一定会在索引中加上主键吗

    InnoDB一定会在索引中加上主键吗 http://www.penglixun.com/tech/database/will_innodb_store_pk_in_index.html

  2. 转载:C语言的谜题

    转载:http://coolshell.cn/articles/945.html 这几天,本站推出了几篇关于C语言的很多文章如下所示: 语言的歧义 [酷壳链接] [CSDN链接] 谁说C语言很简单? ...

  3. 如何清除win7开机密码

    一.电脑已经登录到系统,但是忘记了密1对于这种情况是最简单的,其实只需要将密码取消就可以了右键单击桌面上我的电脑,选择管理即可进入计算机管理界面2依次展开系统工具--本地用户和组--用户,在右侧选择要 ...

  4. 【SQL server】安装和配置

    (1)SQL sever 版本问题1: SQL sever 2000 .SQL sever 2005.SQL sever 2008 .SQL sever 2008 R2 安装的时候需要注意是SQL s ...

  5. 线段相交 poj 1066

    // 线段相交 poj 1066 // 思路:直接枚举每个端点和终点连成线段,判断和剩下的线段相交个数 // #include <bits/stdc++.h> #include <i ...

  6. C++ 我想这样用(二)

    话接上篇,从纯C环境转C++环境需要注意些什么呢? 没错,虽然C++曾号称兼容C,而且很多人甚至觉得C就是C++子集,但是c脑残粉一定知道,两者有很大的不同! 下面这些要点是比较突出的,后期我再补充其 ...

  7. [HIve - LanguageManual] Joins

    Hive Joins Hive Joins Join Syntax Examples MapJoin Restrictions Join Optimization Predicate Pushdown ...

  8. L0、L1与L2范数、核范数(转)

    L0.L1与L2范数.核范数 今天我们聊聊机器学习中出现的非常频繁的问题:过拟合与规则化.我们先简单的来理解下常用的L0.L1.L2和核范数规则化.最后聊下规则化项参数的选择问题.这里因为篇幅比较庞大 ...

  9. [转]SQL中char、varchar、nvarchar的区别

    char    char是定长的,也就是当你输入的字符小于你指定的数目时,char(8),你输入的字符小于8时,它会再后面补空值.当你输入的字符大于指定的数时,它会截取超出的字符.   nvarcha ...

  10. cocos2d-x图片变灰或者变亮

    //根据现有CCSprite,变亮和变灰 CCSprite* FlyLeaf::graylightWithCCSprite(CCSprite* oldSprite,bool isLight) {    ...