Skip to content

Instantly share code, notes, and snippets.

@JSila
Created September 8, 2016 20:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JSila/268581a419d324ee557cfdf32c3b2e7e to your computer and use it in GitHub Desktop.
Save JSila/268581a419d324ee557cfdf32c3b2e7e to your computer and use it in GitHub Desktop.
karma test runner example (with webpack)
var webpackConfig = require('./webpack.config')
webpackConfig.entry = undefined
module.exports = function (config) {
config.set({
browsers: ['Chrome'],
files: [
'tests.webpack.js' // karma only needs to know where test files are. if you include source files, you are gonna have a bad time.
],
frameworks: ['mocha'],
preprocessors: {
'tests.webpack.js': ['webpack']
},
reporters: ['progress'],
singleRun: true,
webpack: webpackConfig,
webpackMiddleware: {
noInfo: true,
}
});
};
// tells karma where test files are located
// test files live in src and end with .spec.js
var testsContext = require.context("./src", true, /\.spec\.js$/);
testsContext.keys().forEach(testsContext);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment