Skip to content

Commit

Permalink
fix: pass on error to callback for better error messages (#262)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinteo authored and joshwiens committed Oct 5, 2017
1 parent 9e35089 commit 466581f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/karma-webpack.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 &&
Expand All @@ -185,7 +185,7 @@ Plugin.prototype.make = function(compilation, callback) {
})
this.middleware.invalidate()
}
callback()
callback(err)
}.bind(this))
}.bind(this), callback)
}
Expand Down
24 changes: 24 additions & 0 deletions test/unit/plugin.test.js
Original file line number Diff line number Diff line change
@@ -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()
})
})
})
})

0 comments on commit 466581f

Please sign in to comment.