This Question is Answered

1 "helpful" answer available (2 pts)
6 Replies Last post: Dec 18, 2013 8:03 PM by Magnus Lassi  
Magnus Lassi Newbie 4 posts since
Dec 17, 2013
Currently Being Moderated

Dec 17, 2013 8:25 PM

unexpected token errors when running karma plugin in WebStorm with jasmine and angular directives using external templates

I'm trying to test angular directives that uses an external template with Jasmine running with Karma in WebStorm. I'm using OS X Mavericks and use WebStorm 7.0.2 and Karma version 0.10.2. I'm using the Karma runner in Webstorm that comes with Webstorm 7+.

I cloned Vojta Jina's angular directive testing project from git: . I haven't made any changes to the karma config file. If I run Karma from WebStorm I get the errors:

/usr/local/bin/node /Applications/ --karmaPackageDir=/Users/mags/WebstormProjects/node_modules/karma --serverPort=9876 --urlRoot=/
Testing started at 4:11 PM ...

Uncaught SyntaxError: Unexpected token <
at http://localhost:9876/base/tpl/pane.html?1387211367000:1

Uncaught SyntaxError: Unexpected token <
at http://localhost:9876/base/tpl/tabs.html?1387211367000:1

Process finished with exit code 0

If I run karma from terminal or just open a terminal window inside of WebStorm it executes fine:

karma start
WARN [karma]: Port 9876 in use
INFO [karma]: Karma v0.10.2 server started at http://localhost:9877/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 31.0.1650 (Mac OS X 10.9.0)]: Connected on socket X9kMCrZtNco2FEPaSEfb
Chrome 31.0.1650 (Mac OS X 10.9.0): Executed 9 of 9 SUCCESS (0.418 secs / 0.101 secs)

I have installed the karma-ng-html2js-preprocessor before but I think it comes bundled with karma now anyway.

Is there anything that needs to be changed in configuration karma configuration in WebStorm? I have also tried to set it up differently in a separate project without using any of the code from Vojta's repository but I get the same errors when I run it from WebStorm.




Elena Pogorelova Expert 1,850 posts since
Oct 5, 2011



all I needed to do to make your project run successfully in WebStorm was installing the karma-ng-html2js-preprocessor (npm install karma-ng-html2js-preprocessor -g). I got exactly the same errors on first run (not having karma-ng-html2js-preprocessor installed) plus a message from karma server about missing module. Installing the module fixed the issue for me

Elena Pogorelova Expert 1,850 posts since
Oct 5, 2011

Please can you provide the full content of the Karma server tab of the Run tool window (when you run karma from WebStorm)?


Just tried this on MacOSX 10.9.0, without themodule installed:


/usr/local/bin/node "/Applications/WebStorm" --karmaPackageDir=/usr/local/lib/node_modules/karma --configFile=/Users/tester/WebstormProjects/angular_dir_karma/karma.conf.js --coverageTempDir=/private/var/folders/_v/5_pp_vxx6gx4_y3x3qnl_bh00000gq/T/karma-intellij-coverage-5639959271835623119.tmp
INFO [karma]: Karma v0.10.8 server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
WARN [preprocess]: Can not load "ng-html2js", it is not registered!
Perhaps you are missing some plugin?

Installing the module globally cured the problem immediately - tests run fine
Elena Pogorelova Expert 1,850 posts since
Oct 5, 2011

hmm... Seems you have karma installed locally (karmaPackageDir=/Users/magnus/WebstormProjects/node_modules/karma)? I have both karma and

ng-html2js installed globally


See also,

More Like This

  • Retrieving data ...