运行测试时EmberJS全局错误

roc*_*323 5 javascript ember.js ember-testing ember-cli

我正在尝试使用Ember Testing集成自动化测试.

应用程序在浏览器上运行正常,没有任何错误.我试过简单地跑步

ember test
Run Code Online (Sandbox Code Playgroud)

在命令行上,但得到一堆全局错误,所有测试都失败了.

这些是我得到的错误:

not ok 1 PhantomJS 2.1 - Global error: SyntaxError: Unexpected token ',' at http://localhost:4302/assets/vendor.js, line 145617

not ok 2 PhantomJS 2.1 - Global error: Error: Could not find module ember-metal/core required by: ember-testing/index at http://localhost:4302/assets/test-support.js, line 62

not ok 3 PhantomJS 2.1 - Global error: ReferenceError: Can't find variable: define at http://localhost:4302/assets/tests.js, line 1

...
Run Code Online (Sandbox Code Playgroud)

当我在浏览器上运行测试时,我没有得到语法错误(上面的第一个),第一个错误是

Uncaught Error: Could not find module `analogue/resolver` imported from `analogue/tests/helpers/resolver`
Run Code Online (Sandbox Code Playgroud)

这些对我来说没有意义,因为我不应该编辑vendor.js和它说它找不到的模块.有任何想法吗?

Ivo*_*ijk 3

万一其他人(像我一样)最终遇到类似的问题。

在我的例子中,错误列表总是以随机 SyntaxError 开头(有时关于“(”或“!”)。实际引用的行通常甚至不包含这些符号。

我的解决方案是将 phantomjs 从 2.1 降级到 1.9 版本

npm install -g phantomjs@1.9.20
Run Code Online (Sandbox Code Playgroud)

(在这些情况下使用nvmnave使您的生活更轻松)