nikku/karma-browserify

Unable to use karma-browserify when using browserify-shim

pelizza opened this issue · 3 comments

I'm trying to use karma-browserify together with browserify-shim with no success. Here is a repo to reproduce the error: https://github.com/pelizza/karma-browserify-shim

PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
TypeError: undefined is not an object (evaluating 'module.exports = ex')
at /var/folders/_0/ql88mbyd6v34qsmysr5kf4780000gn/T/e0c5e5ebe3f49930de3d988c7196737f.browserify:40308 <- bower_components/jquery/dist/jquery.js:9837:0

Everything works fine when bundling with browserify, by it seems that karma simply doesn't find shimmed dependencies when preprocessing files with karma-browserify. I couldn't find much about this problem, except this one at stack overflow, without a solution: http://stackoverflow.com/questions/29050811/karma-browserify-throws-error-when-trying-to-load-modules-shimmed-with-browserif

nikku commented

I've got no idea about browserify-shim. But as you added it to your package.json as a transform it should not be necessary to redeclare it as part of the Karma configuration.

I may be wrong about that 😉.

Yep, you are totally right. That fixed the problem :)

Also, I just updated the repo removing browserify-shim from karma configuration.

Thanks!

Use Chrome instead of Phantom and your problem may go away :)