2016-07-20 61 views
4

我正尝试使用Ember测试集成自动化测试。EmberJS运行测试时出现全局错误

该应用程序在浏览器上正常运行,没有任何错误。我尝试了简单的运行

ember test 

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

这是我得到的错误:

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 

... 

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

Uncaught Error: Could not find module `analogue/resolver` imported from `analogue/tests/helpers/resolver` 

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

+0

您使用的是什么版本的烬? – dustinfarris

+0

是否安装了所有[先决条件](https://ember-cli.com/user-guide/#prerequisites)?主要phantomjs –

+0

你有没有试过用'-s'标志在浏览器中运行测试并查看浏览器控制台?有时有错误,很容易理解有 – GUL

回答

3

如果有其他人(像我)在这里结束了类似的问题。

在我而言总是始于一个随机的SyntaxError(有时约“(”或“!”)的错误列表,实际参考线平时从不甚至包含这些符号。

对我来说,解决办法是降级从2.1 phantomjs到1.9版本

npm install -g [email protected] 

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

0

在我来说,我只是需要一个全新的phantomJS安装

npm uninstall phantomjs -g 
npm install phantomjs -g 
相关问题