diff --git a/src/karma-webpack.js b/src/karma-webpack.js index 2997b29..65c0d5b 100644 --- a/src/karma-webpack.js +++ b/src/karma-webpack.js @@ -175,7 +175,7 @@ Plugin.prototype.make = function(compilation, callback) { var dep = new SingleEntryDependency(entry) - compilation.addEntry('', dep, path.relative(this.basePath, file).replace(/\\/g, '/'), function() { + compilation.addEntry('', dep, path.relative(this.basePath, file).replace(/\\/g, '/'), function(err) { // If the module fails because of an File not found error, remove the test file if (dep.module && dep.module.error && dep.module.error.error && @@ -185,7 +185,7 @@ Plugin.prototype.make = function(compilation, callback) { }) this.middleware.invalidate() } - callback() + callback(err) }.bind(this)) }.bind(this), callback) } diff --git a/test/unit/plugin.test.js b/test/unit/plugin.test.js new file mode 100644 index 0000000..7a40f01 --- /dev/null +++ b/test/unit/plugin.test.js @@ -0,0 +1,24 @@ +import {assert} from 'chai' +import {webpackPlugin} from '../../src/karma-webpack' + +describe('Plugin', function() { + describe('#make()', function() { + it('should pass through error from compilation', function(done) { + var emitterMock = { + on() {} + } + var compilationMock = { + addEntry(name, dep, file, cb) { + cb(new Error('test error')) + } + } + var Plugin = new webpackPlugin[1]({}, {}, {}, '', [], [], [], emitterMock) + + Plugin.addFile('test.js') + Plugin.make(compilationMock, function(err) { + assert.equal(err.message, 'test error') + done() + }) + }) + }) +})