Configuring karma to work with webpack

This commit is contained in:
Jeff Avallone 2016-10-15 12:33:28 -04:00
parent a8a76651c2
commit 2a496bf4c1
3 changed files with 13 additions and 19 deletions

View File

@ -1,30 +1,21 @@
var _ = require('lodash'),
config = require('./config');
var webpack = require('./webpack.config.js');
module.exports = function(karma) {
var globs = _.flatten([
config.globs.js,
config.globs.spec
]);
karma.set({
frameworks: ['browserify', 'jasmine'],
files: globs,
preprocessors: _(globs)
.zipObject()
.mapValues(_.constant(['browserify']))
.valueOf(),
files: [ 'spec/test_index.js' ],
preprocessors: {
'spec/test_index.js': ['webpack', 'sourcemap']
},
reporters: ['progress', 'notify'],
colors: true,
logLevel: karma.LOG_INFO,
browsers: ['Firefox'],
autoWatch: true,
singleRun: false,
browserify: _.extend({
configure: function(bundler) {
bundler.transform(require('./lib/canopy-transform'));
bundler.transform(require('babelify'));
}
}, config.browserify)
webpack: {
devtool: 'inline-source-map',
module: webpack.module
}
});
};

View File

@ -33,10 +33,11 @@
"imports-loader": "^0.6.5",
"jasmine-core": "^2.4.1",
"karma": "^1.1.2",
"karma-browserify": "^5.0.2",
"karma-firefox-launcher": "^1.0.0",
"karma-jasmine": "^1.0.2",
"karma-notify-reporter": "^1.0.1",
"karma-sourcemap-loader": "^0.3.7",
"karma-webpack": "^1.8.0",
"lodash": "^4.6.1",
"node-bourbon": "^4.2.3",
"snapsvg": "^0.4.0",

2
spec/test_index.js Normal file
View File

@ -0,0 +1,2 @@
var testsContext = require.context(".", true, /_spec$/);
testsContext.keys().forEach(testsContext);