意外的令牌'>'使用Array.some()使用Karma和PhantomJS

时间:2016-08-18 20:23:43

标签: unit-testing phantomjs karma-runner

我收到以下错误:

PhantomJS 2.1.1 (Windows 7 0.0.0) ERROR
   SyntaxError: Unexpected token '>'
   at myAngularControllerPath.js:9

导航到该文件我发现我正在使用Array.some()函数,如下所示:

return list.some(x => isListItemGood(x));

当我使用karma.conf.js文件中指定的Chrome运行Karma时,我没有收到此错误。

根据http://kangax.github.io/compat-table/es5/,PhantomJS支持ES5的所有10个新阵列功能,并且根据https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/some在ES5中引入了Array.some()。我用' npm install安装了PhantomJS --save-dev karma-phantomjs-launcher' 2.1.7在其依赖项中列为PhantomJS版本。

感谢您的帮助!

1 个答案:

答案 0 :(得分:12)

"Arrow functions" are not supported by PhantomJS 2.x

PhantomJS仅支持ES6的一小部分。

相关问题