[Webpack 2] Ensure all source files are included in test coverage reports with Webpack
If you’re only instrumenting the files in your project that are under test then your code coverage report will be misleading and it will be difficult for you to track or enforce improvements to application coverage over time. In this lesson we’ll learn how to ensure all source files are included in coverage reports and how to enforce a specific threshold so you can work toward improving application code coverage.
Install:
npm i -D istanbul
Include all the src code not only test code:
const webpackEnv = {test: true}
const webpackConfig = require('./webpack.config')(webpackEnv)
process.env.BABEL_ENV = 'test' // so we load the correct babel plugins
const testGlob = 'src/js/**/*.test.js'
const srcGlob = 'src/js/**/*!(test|stub).js'
module.exports = function setKarmaConfig(config) {
config.set({
basePath: '',
frameworks: ['mocha', 'chai'],
files: [testGlob, srcGlob],
preprocessors: {
[testGlob]: ['webpack'],
[srcGlob]: ['webpack'],
},
webpack: webpackConfig,
webpackMiddleware: {noInfo: true},
reporters: ['progress', 'coverage'],
coverageReporter: {
reporters: [
{type: 'lcov', dir: 'coverage/', subdir: '.'},
{type: 'json', dir: 'coverage/', subdir: '.'},
{type: 'text-summary'},
],
},
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: false,
browsers: ['Chrome'],
singleRun: true,
concurrency: Infinity
})
}
Use istanbul cli to check code coverage not below cetain number:
"check-coverage": "istanbul check-coverage --statements 23 --branches 5 --functions 9 --lines 24",
Add to validator:
"validate": "npm-run-all --parallel validate-webpack:* lint test --serial check-coverage",
Because it checkout coverage should run after test, so add '--serial' flag
[Webpack 2] Ensure all source files are included in test coverage reports with Webpack的更多相关文章
- android C/C++ source files 全局宏定义 .
\system\core\include\arch\linux-arm AndroidConfig.h * ============================================== ...
- VC中Source Files, Header Files, Resource Files,External Dependencies的区别
VC中Source Files, Header Files, Resource Files,External Dependencies的区别 区别: Source Files 放源文件(.c..cpp ...
- Using command-line Subversion to access project source files
Help index About source code version control with Software Configuration Management (Subversion) Usi ...
- webpack ------require,ensure
require-ensure和require-amd的区别: require-amd 说明: 同AMD规范的require函数,使用时传递一个模块数组和回调函数,模块都被下载下来且都被执行后才执行回调 ...
- vue项目优化之按需加载组件-使用webpack require.ensure
require-ensure和require-amd的区别: require-amd 说明: 同AMD规范的require函数,使用时传递一个模块数组和回调函数,模块都被下载下来且都被执行后才执行回调 ...
- VScode-Go can't load package: package .: no buildable Go source files in
在VScode中调试Go程序时提示: can't load package: package .: no buildable Go source files in d:\my_workspace\go ...
- golang 版本升降之后报错——imports runtime: C source files not allowed when not using cgo or SWIG
问题: golang 升级或者降级版本之后,执行编译报错如下: package github.com/onsi/ginkgo/ginkgo imports runtime: C source file ...
- 对vue中 默认的 config/index.js:配置的详细理解 -【以及webpack配置的理解】-config配置的目的都是为了服务webpack的配置,给不同的编译条件提供配置
当我们需要和后台分离部署的时候,必须配置config/index.js: 用vue-cli 自动构建的目录里面 (环境变量及其基本变量的配置) var path = require('path') ...
- webpack打包出现WARNING in configuration The 'mode' option has not been set, webpack will fallback to 'production' for this value. 错误
打包运行的时候出现以下错误 WARNING in configurationThe 'mode' option has not been set, webpack will fallback to ' ...
随机推荐
- apache的 .htaccess文件的常用配置
使用.htaccess文件需要注意的地方: 1.找到配置文件httpd.conf,将override的值改成all.如下图:(如果不设置成all,apache将忽略.htaccess文件)
- Java集合ArrayList的应用
/** * * @author Administrator * 功能:Java集合类ArrayList的使用 */ package com.test; import java.io.BufferedR ...
- 【HDOJ】1069 Monkey and Banana
DP问题,我是按照边排序的,排序既要考虑x也要考虑y,同时在每个面中,长宽也要有序.还有注意状态转移,当前高度并不是之前的最大block叠加的高度,而是可叠加最大高度+当前block高度或者是当前bl ...
- Android开发之注解式框架ButterKnife在ADT中的设置
使用注解式框架ButterKnife的时候,导入到ADT中,结果项目中注解的view无效,如点击button等无任何的反应. 然后在ButterKnife的官网查看到解决办法:http://jakew ...
- 如何计算IP地址及CIDR,子网掩码计算
如何计算IP地址及CIDR 一. IP地址概念 IP地址是一个32位的二进制数,它由网络ID和主机ID两部份组成,用来在网络中唯一的标识的一台计算机.网络ID用来标识计算机所处的网段:主 机ID用来标 ...
- @Resource和@Autowired
@Resource的作用相当于@Autowired,只不过@Autowired按byType自动注入,而@Resource默认按 byName自动注入罢了.@Resource有两个属性是比较重要的,分 ...
- POJ_1269_Intersecting_Lines_(计算几何基础)
描述 http://poj.org/problem?id=1269 给出两条直线,判断它们是平行,重合,还是相交,如果相交,求出交点. 分析 比较裸的一道题.学习了直线的写法(参数方程) #inclu ...
- SharePoint Site Pages & Application Pages
转:http://www.wcode.net/plus/view.php?aid=1582071 SharePoint一个很重要的概念就是Site Pages和Application Pages.接触 ...
- 安全delete,添加refenerce,release
#ifndef SAFE_ADDREF#define SAFE_ADDREF(p) if (p != NULL) { p->AddRef(); }#endif #ifndef SAFE_R ...
- Monkey的简单自动化
手机测试都逃避不了Monkey,但每次都是手动跑Monkey,自己导出包来,一条条的手动输入命令. 现在轮到我去执行这些任务,觉得很是繁琐,于是写了这个脚本,自动读取导出的包名,一键回车搞定. 代码如 ...