Closed pchudzik closed 7 years ago
I don't think it's appropriate for this project to add and document hacks for a specific IDE
Glad you created that issue and good to know there exists an actual workaround.
We won't include that hack into our project, for the reasons @bendrucker outlined.
Others interested in a workaround may resort to your hack.
It's hack for one particular IDE (maybe more than one because there is intellij, webstorm, phpstorm, etc) and I'm not surprised that you decided to decline it :)
In case anybody stumbles on this I've decided to fix it and publish to npm (it's more convenient for me to use package from npm instead of github link): http://npmjs.com/package/karma-browserify-intellij https://github.com/pchudzik/karma-browserify
I will try to keep my fork up to date, and maybe one day jet brains will fix it...
When running karma tests from intellij autoWatch flag is always overwritten to false - https://github.com/JetBrains/intellij-plugins/blob/master/js-karma/src/js_reporter/karma-intellij/lib/intellij.conf.js#L56 (https://youtrack.jetbrains.com/issue/WEB-14437)
For small projects it doesn't really matter but in case project is big then bundling all js files can tak up to 20-30 seconds (with all the sources, and external dependencies).
karma-browserify depends on autoWatch = true which will trigger watchify. Now since idea always overwrite autoWatch to false then it's impossible to use watchify when running tests from idea. It means that every time I want to run tests I need to wait 20+ seconds for browserify to bundle from scratch :(
I've created ugly workaround for this - https://github.com/pchudzik/karma-browserify/commit/10ee655d8bf489cc2ff315815847e67410f0af3b With this bundle is built with watchiy in less than 1s. I can create proper PR with test and documentation but the question is will you accept this ugly workaround dedicated for intellij? It's basically the same as in https://github.com/nikku/karma-browserify/pull/24 but It wasn't merge because of https://youtrack.jetbrains.com/issue/WEB-12496 for which there is a workaround: In file ~/.IntelliJIdea2016.3/config/plugins/js-karma/js_reporter/karma-intellij/lib/intellijRunner.js find function runTests and change runWithConfig invocation param refresh to true. It should look like this:
Configuration object applied on bro.js when using intellij's karma runner