Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: pass on error to callback for better error messages #262

Merged
merged 1 commit into from
Oct 5, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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'
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's avoid using unit directory for test file.

Copy link
Contributor Author

@vinteo vinteo Sep 13, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is an existing folder (for the demo test) and the current test config doesn't support it in the root test folder. What name do you suggest?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vinteo oh sorry, i think we update tests (migrate to jest) in this repo, do nothing, leave everything as is 👍

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()
})
})
})
})