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. javascript的族家族史

    JavaScript 实现 完整的 JavaScript 实现是由以下 3 个不同部分组成的:ECMAScript.文档对象模型.浏览器对象模型.这也就是说 cocos2d-js 中 其实我们用的是 ...

  2. 用C++ 设计一个不能被继承的类

    http://blog.sina.com.cn/s/blog_69d9bff30100odlz.html 在Java 中定义了关键字final ,被final 修饰的类不能被继承.但在C++ 中没有f ...

  3. OpenSSH ‘mm_newkeys_from_blob’函数权限许可和访问控制漏洞

    漏洞名称: OpenSSH ‘mm_newkeys_from_blob’函数权限许可和访问控制漏洞 CNNVD编号: CNNVD-201311-117 发布时间: 2013-11-12 更新时间: 2 ...

  4. POJ 1840 Eps 解题报告(哈希)

    a1x13+ a2x23+ a3x33+ a4x43+ a5x53=0,xi∈[-50,50],且xi!=0.让我们求所有解的可能. 首先,如果暴力判断的话,每个x的取值有100种可能,100^5肯定 ...

  5. Embedding Documents in Word 2007 by Using the Open XML SDK 2.0 for Microsoft Office

    Download the sample code This visual how-to article presents a solution that creates a Word 2007 doc ...

  6. iPhone丢失后通过iccid找回流程

    切记,丢失IPHONE第一时间要去补卡,免得小偷刷机用你的卡激活,这样你查到的号码只会是你自己的号码找iphone有2个方法:ICCID和维修换机.两者之间没任何直接联系,请不要混淆!下面是总体流程图 ...

  7. LoadRunner调用Java程序—性能测试-转载

    LoadRunner调用Java程序—性能测试   为了充分利用LoadRunner的场景控制和分析器,帮助我们更好地控制脚本加载过程,从而展现更直观有效的场景分析图表.本次将重点讨论LoadRunn ...

  8. ActiveMQ的安全机制使用及其源代码分析 [转]

    ActiveMQ是目前较为流行的一款开源消息服务器.最近在项目开发中,需要为ActiveMQ开发基于IP的验证和授权机制,因此,对ActiveMQ的安全机制进行了了解,以下将介绍ActiveMQ的安全 ...

  9. 五指CMS发布1.4版本,更多的新功能

    五指cms v1.4变更: 新增内容手动分页新增百度地图新增订单管理模块新增订单地址管理增加Microsoft YaHei字体新增推广邀请模块新增私密下载,下载函数 新增百度地图新增筛选功能 修正全局 ...

  10. POJ 1321 棋盘问题 DFS搜索

    简单搜索 练习一下回溯 #include <iostream> #include <cstdio> #include <cstring> #include < ...