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的更多相关文章

  1. android C/C++ source files 全局宏定义 .

    \system\core\include\arch\linux-arm AndroidConfig.h * ============================================== ...

  2. VC中Source Files, Header Files, Resource Files,External Dependencies的区别

    VC中Source Files, Header Files, Resource Files,External Dependencies的区别 区别: Source Files 放源文件(.c..cpp ...

  3. Using command-line Subversion to access project source files

    Help index About source code version control with Software Configuration Management (Subversion) Usi ...

  4. webpack ------require,ensure

    require-ensure和require-amd的区别: require-amd 说明: 同AMD规范的require函数,使用时传递一个模块数组和回调函数,模块都被下载下来且都被执行后才执行回调 ...

  5. vue项目优化之按需加载组件-使用webpack require.ensure

    require-ensure和require-amd的区别: require-amd 说明: 同AMD规范的require函数,使用时传递一个模块数组和回调函数,模块都被下载下来且都被执行后才执行回调 ...

  6. 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 ...

  7. 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 ...

  8. 对vue中 默认的 config/index.js:配置的详细理解 -【以及webpack配置的理解】-config配置的目的都是为了服务webpack的配置,给不同的编译条件提供配置

    当我们需要和后台分离部署的时候,必须配置config/index.js: 用vue-cli 自动构建的目录里面  (环境变量及其基本变量的配置) var path = require('path') ...

  9. 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 ' ...

随机推荐

  1. [TSP+floyd]POJ3311 Hie with the Pie

    题意: 给i到j花费的地图 1到n编号   一个人要从1遍历n个城市后回到1 求最小的花费(可以重复走) 分析 http://www.cnblogs.com/Empress/p/4039240.htm ...

  2. QTY N.W G.W

    QTY(Quantity) - 数量 [英文缩写]QTY[英文全称]Quantity[中文解释]数量 A.毛重:Gross Weight是指商品本身的重量加皮重(tare),也即商品连同包装的重量.有 ...

  3. RichEdit 各个版本介绍

    RichEdit是开发中经常使用到的控件,其版本自1.0起,历经好几年,好几次的更新,在此引用一篇介绍RichEdit版本的博文(http://blogs.msdn.com/b/murrays/arc ...

  4. 添加service到SystemService硬件服务

    添加service到SystemService: 添加硬件服务. 创建时间:2015年3月9日(星期一) 晚上11:07 | 分类:硬件驱动Android | 天气: 修改时间:2015年3月10日( ...

  5. 登陆与注册以及Session

    Session  保存状态是在 登陆窗口  检查用户密码的动作上执行 .Models namespace 注册与登陆以及Session.Models { public class UserBF { p ...

  6. BZOJ_3039_玉蟾宫_(动态规划+悬线法)

    描述 http://www.lydsy.com/JudgeOnline/problem.php?id=3039 n*m的矩阵由R和F组成,求全是F的子矩阵的大小的三倍. 分析 悬线法: 浅谈用极大化思 ...

  7. Master Nginx(3) - Using the Mail Module

    Basic proxy service Authentication service Combining with memcached Interpreting log files Operating ...

  8. Azure Site Recovery:我们对于保障您的数据安全的承诺

    Anoob Backer 云 + Enterprise 项目经理  Azure Site Recovery是一个基于 Azure的全天候.易用的服务,可以安全地安排恢复操作,一旦发生灾难,即可为您 ...

  9. keychain中我的证书与证书, p12与pem, apns, 推送

    如果在A电脑上生成 的apns, 到B电脑上导入此文件时, 在 "我的证书"中找不到, 要去"证书"才能找到, 因为 创建时的csr不是本机生成的. 那这样的话 ...

  10. wpa_supplicant 与iwpriv工具配置WIFI的命令

    =====================================================hostapd 配置命令=================================== ...