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

转载于:https://www.cnblogs.com/Answer1215/p/5625494.html

[Webpack 2] Ensure all source files are included in test coverage reports with Webpack相关推荐

  1. 【Compiling Swift source files】编译很慢;

    [Compiling Swift source files]编译很慢:  [解决]Edit Scheme -> Build Configuration,设置为[Debug]  [总结:自 ...

  2. jenkins source files 和 Remove Prefix 用户

    转自:https://www.jianshu.com/p/11a89d6991bb jenkins 构建后传输文件到服务器 在部署前端项目的时候需要将打包生成的dist文件夹传输到服务器特定目录.而链 ...

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

  4. STM32 软件 I2C Source Files (No Clock Strech)

    STM32 软件 I2C Source Files (No Clock Strech) ** 验证程序:** const uint8_t ucPattern[8] = { 0x55, 0xAA, 0x ...

  5. 【Flutter 笔记系列 第 3 篇】如何正确对待Name source files using `lowercase with underscores`

    相信很多安装了一些提示插件的小伙伴都遇见过 Name source files using `lowercase with underscores` flutter  提示 如下图 此时会有两种选择 ...

  6. c语言resource files的作用,VC中Source Files, Header Files, Resource Fil

    VC++6.0中Source Files,Header Files,Resource Files,External Dependencies区别 Source Files 放源文件(.c..cpp)程 ...

  7. c语言resource files的作用,VC中Source Files, Header Files, Resource Files,External Dependencies的作用...

    VC中Source Files, Header Files, Resource Files,External Dependencies的作用 很久没有用过VC了,突然觉得想整理出来简单基本的东西: S ...

  8. 记录一个问题xxx: no Go source files

    现象是在命令行执行go run main.go的时候是可以执行的,但是我在goland去run的时候,就报错xxx: no Go source files给我看,原因应该是在import包的时候,我手 ...

  9. vue按需加载组件-webpack require.ensure(转)

    vue按需加载组件-webpack require.ensure 2017年07月28日 09:58:07 A_山水子农 阅读数:23245 标签: vue按需加载组件按需加载webpackrequi ...

最新文章

  1. 「乾坤」学霸同保送!双胞胎帅哥一起上北大,哥哥本科发表2篇SCI
  2. 【转载】windows mobile 上隐藏和关闭X以及OK的处理
  3. 四、Go语言复合数据类型(上)
  4. 【原】基础篇:第一篇,本节主要向大家介绍Ext的最基础的话题
  5. 为什么c语言2的n次方减一,计算2的N次方........有什么错吗?
  6. 关于结构体的浅拷贝和深拷贝
  7. 为什么运营商的机顶盒(IPTV)看直播不卡?
  8. pt-archiver详解
  9. Packet Tracer 思科模拟器入门教程 之十一 路由器静态路由配置
  10. MMDetection框架入门教程(完全版)
  11. 新入职的程序员如何更快的融入项目当中?
  12. IDEA导入UAPStudio(Eclipse)创建的项目
  13. python自己做课程表_Kivy做一个课程表App(上)
  14. 组建无线网络的六条思路
  15. 51单片机的串行接口介绍
  16. “全国名中医学术经验传承暨经方临证与五运六气经典”高级研修班
  17. pandas读取文件数据、存储详解笔记
  18. SQL中的DECIMAL()函数
  19. 家庭版安装DotNetFX35
  20. 【题解】LuoGu4610:[COI2012] KAMPANJA

热门文章

  1. 克隆管理员帐号的方法
  2. 汇编-子程序参数传递的三种方式-寄存器法,堆栈法,参数赋值法【详述后两者】
  3. 2440 nand flash和nor flash上启动
  4. S3C2440启动代码分析
  5. HDU1569 方格取数(2)(二分图带权最大独立集 - 最小割应用)
  6. Codeforces Round #528 (Div. 2) - D. Minimum Diameter Tree
  7. facenet 中心损失函数(center loss)详解(代码分析)含tf.gather() 和 tf.scatter_sub()函数
  8. C++11: std::function<void()> func
  9. c++-内存管理-array allocator
  10. SVN switch 用法详解