From 2a496bf4c18f4af2a04d9c07fab2cee4d9256b29 Mon Sep 17 00:00:00 2001 From: Jeff Avallone Date: Sat, 15 Oct 2016 12:33:28 -0400 Subject: [PATCH] Configuring karma to work with webpack --- karma.conf.js | 27 +++++++++------------------ package.json | 3 ++- spec/test_index.js | 2 ++ 3 files changed, 13 insertions(+), 19 deletions(-) create mode 100644 spec/test_index.js diff --git a/karma.conf.js b/karma.conf.js index b72a8f7..9568c8b 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -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 + } }); }; diff --git a/package.json b/package.json index f793b05..e5d7c4a 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/spec/test_index.js b/spec/test_index.js new file mode 100644 index 0000000..55b8b0d --- /dev/null +++ b/spec/test_index.js @@ -0,0 +1,2 @@ +var testsContext = require.context(".", true, /_spec$/); +testsContext.keys().forEach(testsContext);