Created
June 4, 2015 21:40
-
-
Save frederickfogerty/f07f389c58ad1fdd28bc to your computer and use it in GitHub Desktop.
Coverage + tests with webpack, babel, karma, mocha, and istanbul
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var webpack = require('webpack') | |
module.exports = function (config) { | |
config.set({ | |
browsers: [ 'Chrome' ], //run in Chrome | |
browserNoActivityTimeout: 60000, | |
singleRun: true, //just run once by default | |
frameworks: [ 'mocha' ], //use the mocha test framework | |
files: [ | |
//'src/**/*.{jsx,js}', | |
'tests.webpack.js' //just load this file | |
], | |
preprocessors: { | |
'tests.webpack.js': ['webpack', 'sourcemap' ], //preprocess with webpack and our sourcemap loader | |
//'src/**/*.jsx?': ['coverage'] | |
}, | |
reporters: [ 'mocha', 'coverage' ], //report results in this format | |
mochaReporter: { | |
output: 'autowatch' | |
}, | |
coverageReporter: { | |
reporters: [ | |
{type: 'text'}, | |
{type: 'html'} | |
] | |
}, | |
webpack: { | |
devtool: 'inline-source-map', | |
module: { | |
loaders: [ | |
{ test: /\.jsx?$/, loader: 'babel-loader' } | |
], | |
postLoaders: [ { | |
test: /\.js$/, | |
exclude: /(test|node_modules|bower_components)\//, | |
loader: 'istanbul-instrumenter' | |
} ] | |
} | |
}, | |
webpackServer: { | |
noInfo: true //please don't spam the console when running in karma! | |
} | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var context = require.context('./src', true, /\.test\.jsx?$/) // make sure you have your directory and regex test set correctly! | |
context.keys().forEach(context) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment