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. RMQ(dp)

    我一开始是不知道有这么个东西,但是由于最近在学习后缀数组,碰到一道题需要用到后缀数组+RMQ解决的所以不得不学习了. 原理:用A[1...n]表示一组数,dp[i][j]表示从A[i]到A[i+2^j ...

  2. Chromuim开发机配置

    一个出色的程序员需要一台给力的电脑. 之前使用ThinkPad R400笔记本编译Chromium,确实太痛苦了,第一次编译未使用SSD,超过了24小时都没有编译完.后来断断续续折腾了将近一个月才编译 ...

  3. LeetCode题解——Longest Common Prefix

    题目: 给定一系列的字符串,找出这些字符串的最长公共前缀. 解法: 暴力法,依次比较每个字符串的每个字符,碰到第一个不同的就返回之前找到的前缀. 代码: class Solution { public ...

  4. php上传文件时出现错误:failed to open stream: Permission denied

    尝试使用php写了一段小的上传程序,但是在使用的时候,在上传文件时出现这个错误,由于之前在写程序要读文件,曾经出现过这个问题,当时是因为要读的文件的权限不够,于是使用chmod 775 1.txt把文 ...

  5. document.getElementsByClassName方法的重写(OVERRIDE)

    众所周知,对于IE8以下的浏览器(IE8居然是WIN7预装的)没有document.getElementsByClassName,网上也有很多重写的方法,以下是本人在项目中所使用的方法 documen ...

  6. [微软实习生2014]K-th string

    很久之前的事情了,微软2014实习生的在线测试题,记录下来以备后用. 题目描述: Description Consider a string set that each of them consist ...

  7. Javascript手记-垃圾收集

    如果有人问.net的垃圾回收,大家会马上想到gc,那如果有人问你javascript如何进行内存管理的呢?挠挠头,一口香瓜,听我细细道来! javascript具有自动垃圾收集机制,执行环境会负责管理 ...

  8. 在eclipse中配置spark 0.9.1源码的开发环境

    一.准备工作: 1.下载release版spark 0.9.1,本次用的版本是spark-0.9.1-bin-cdh4. 2.下载scala IDE 3.0.2,这个版本ide的支持scala 2.1 ...

  9. google proto buffer安装和简单示例

    1.安装 下载google proto buff. 解压下载的包,并且阅读README.txt,根据里面的指引进行安装. $ ./configure $ make $ make check $ mak ...

  10. Oracle中纵横表的转化

    横表就是普通的建表方式,如一个表结构为:主键.字段1.字段2.字段3......如果变成纵表后, 则表结构为:主键.字段代码.字段值.而字段代码则为字段1.字段2.字段3. 纵表对从数据库到内存的映射 ...