2016-07-20 59 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 
相關問題