PhantomJS Karma SyntaxError for export

I have a problem starting Karma and PhantomJS. When I try to start, I get this in the console:

22 03 2016 14:58:47.865:WARN [karma]: No captured browser, 
open http://localhost:9876/
22 03 2016 14:58:47.875:INFO [karma]: Karma v0.13.22 server 
started at http://localhost:9876/
22 03 2016 14:58:47.879:INFO [launcher]: Starting browser PhantomJS
22 03 2016 14:58:48.336:INFO [PhantomJS 2.1.1 (Mac OS X 0.0.0)]:
Connected on socket /#lBe2M4kLKnN8N5x0AAAA with id 55603904
PhantomJS 2.1.1 (Mac OS X 0.0.0) ERROR
SyntaxError: Use of reserved word 'export'

I updated all my npm modules for karma, webpack, karma-phantomjs, etc., but still don't understand why this is happening. An example of a file that does not like this:

export default function () {
    // code here
}

Does anyone else run into this problem and figure out how to solve it?

+4
source share
2 answers

You should use Webpack as a preprocessor: https://github.com/webpack/karma-webpack

I personally use this because it is faster: https://github.com/aaronjensen/karma-webpack

:

files: [
  './node_modules/babel-polyfill/dist/polyfill.js',
  './node_modules/phantomjs-polyfill/bind-polyfill.js',
  ...
]
+3

All Articles