add coverage

This commit is contained in:
Kent C. Dodds 2016-06-07 20:43:53 -06:00
parent 6babcb3348
commit 9d9b416940
3 changed files with 19 additions and 2 deletions

View File

@ -1,3 +1,10 @@
{ {
"presets": ["es2015-webpack", "stage-2"] "presets": ["es2015-webpack", "stage-2"],
"env": {
"test": {
"plugins": [
["__coverage__", {"ignore": "*.test.*"}]
]
}
}
} }

View File

@ -1,5 +1,6 @@
const webpackEnv = {test: true} const webpackEnv = {test: true}
const webpackConfig = require('./webpack.config')(webpackEnv) const webpackConfig = require('./webpack.config')(webpackEnv)
process.env.BABEL_ENV = 'test' // so we load the correct babel plugins
const fileGlob = 'src/js/**/*.test.js' const fileGlob = 'src/js/**/*.test.js'
module.exports = function setKarmaConfig(config) { module.exports = function setKarmaConfig(config) {
@ -12,7 +13,14 @@ module.exports = function setKarmaConfig(config) {
}, },
webpack: webpackConfig, webpack: webpackConfig,
webpackMiddleware: {noInfo: true}, webpackMiddleware: {noInfo: true},
reporters: ['progress'], reporters: ['progress', 'coverage'],
coverageReporter: {
reporters: [
{type: 'lcov', dir: 'coverage/', subdir: '.'},
{type: 'json', dir: 'coverage/', subdir: '.'},
{type: 'text-summary'},
],
},
port: 9876, port: 9876,
colors: true, colors: true,
logLevel: config.LOG_INFO, logLevel: config.LOG_INFO,

View File

@ -9,6 +9,7 @@
"babel-core": "6.8.0", "babel-core": "6.8.0",
"babel-eslint": "6.0.4", "babel-eslint": "6.0.4",
"babel-loader": "6.2.4", "babel-loader": "6.2.4",
"babel-plugin-__coverage__": "1.11.111",
"babel-preset-es2015-webpack": "6.4.1", "babel-preset-es2015-webpack": "6.4.1",
"babel-preset-stage-2": "6.5.0", "babel-preset-stage-2": "6.5.0",
"chai": "3.5.0", "chai": "3.5.0",
@ -21,6 +22,7 @@
"karma": "0.13.22", "karma": "0.13.22",
"karma-chai": "0.1.0", "karma-chai": "0.1.0",
"karma-chrome-launcher": "1.0.1", "karma-chrome-launcher": "1.0.1",
"karma-coverage": "1.0.0",
"karma-mocha": "1.0.1", "karma-mocha": "1.0.1",
"karma-webpack": "1.7.0", "karma-webpack": "1.7.0",
"mocha": "2.5.3", "mocha": "2.5.3",