How do I run Karma tests with ES6 + Jasmine

Our build uses Babel + Webpack to compile our code.  We use Karma + Jasmine to run tests.  We have NPM scripts that can drive these.

I can build and run all this from the commandline just fine.  However, I'm not able to get this working in WebStorm.

I first looked at the directions for Karma through WS, and get an error that look like:

06 06 2016 09:10:31.406:ERROR [config]: Error in config file!
[SyntaxError: Unexpected token import]
SyntaxError: Unexpected token import
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:387:25)

I'm assuming this is because I use ES6.  I then tried following the directions to setup a Babel file watcher.  Then I set the Karma, I add "Run File Watchers" to the "Before Launch".

Now, when I click the debug button, I see no indication that anything happened at all.

Then, I set-up an NPM configuration that runs our compile, and tried adding that to the "Before Launch".  This time, I can clearly see the NPM configuration getting run, and it appears to succeed.

Child html-webpack-plugin for "index.html":
Asset Size Chunks Chunk Names
index.html 553 kB 0 +2ms
app:build:webpack-compiler No errors or warnings encountered. +0ms
app:bin:compile Copy css to dist folder. +1ms

Process finished with exit code 0

However, I don't see any karma tests getting run, and my breakpoints are definitely not getting hit. 


P.S.  Sorry, if I posted this twice.  I thought I posted it this weekend, but don't see it. . .

1 comment
Comment actions Permalink

Hmm... When you don't add your NPM script to 'before launch' section, and just run your configurations one-by-one (NPM and then, when it completes, karma) - does the latter work?

Sample project that shows up the issue would be helpful


Please sign in to leave a comment.