5

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

该应用程序在浏览器上运行良好,没有任何错误。我试着简单地跑

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 并且它说它找不到的模块在那里。有任何想法吗?

4

2 回答 2

3

万一其他人(比如我)在这里遇到类似的问题。

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

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

npm install -g phantomjs@1.9.20

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

于 2016-10-04T13:21:51.520 回答
0

就我而言,我只需要一个全新的 PhantomJS 安装

npm uninstall phantomjs -g
npm install phantomjs -g
于 2017-05-16T10:50:40.263 回答