2014-05-14 34 views
3

angular-phonecat教程假設您在裝有chrome的服務器上運行angular-phonecat。如何在無頭服務器上運行angular-phonecat教程測試

輸入npm test後,本地瀏覽器應該打開並連續運行測試。

當然,這不我無頭的服務器上運行:

/var/www/angular-phonecat$ npm test 

> [email protected] pretest /var/www/angular-phonecat 
> npm install 


> [email protected] postinstall /var/www/angular-phonecat 
> bower install 


> [email protected] test /var/www/angular-phonecat 
> karma start test/karma.conf.js 

INFO [karma]: Karma v0.10.10 server started at http://localhost:9876/ 
INFO [launcher]: Starting browser Chrome 
ERROR [launcher]: Cannot start Chrome 
Can not find the binary google-chrome 
Please set env variable CHROME_BIN 

我想這樣做一臺Linux機器是一臺服務器,沒有X安裝。

一種方法將隧道X會話,但我寧願連接npm test環境通過http手動我的本地鉻。

我該怎麼做?

我需要告訴npm test它不應該啓動鉻?我看到服務器在http://localhost:9876/上運行,所以我會手動連接。

angular-phonecat教程假設您在裝有chrome的服務器上運行angular-phonecat。

輸入npm test後,本地瀏覽器應該打開並連續運行測試。

當然,這不我無頭的服務器上運行:

/var/www/angular-phonecat$ npm test 

> [email protected] pretest /var/www/angular-phonecat 
> npm install 


> [email protected] postinstall /var/www/angular-phonecat 
> bower install 


> [email protected] test /var/www/angular-phonecat 
> karma start test/karma.conf.js 

INFO [karma]: Karma v0.10.10 server started at http://localhost:9876/ 
INFO [launcher]: Starting browser Chrome 
ERROR [launcher]: Cannot start Chrome 
Can not find the binary google-chrome 
Please set env variable CHROME_BIN 

我想這樣做一臺Linux機器是一臺服務器,沒有X安裝。

一種方法將隧道X會話,但我寧願連接npm test環境通過http手動我的本地鉻。

我該怎麼做?

我需要告訴npm test它不應該啓動鉻?我看到服務器在http://localhost:9876/上運行,所以我會手動連接。


編輯1:我的嘗試是這樣的,創建一個虛擬的二進制文件,而不是不存在鉻:

/var/www/angular-phonecat$ cat dummy.sh 
#!/bin/sh 
read -p "Press enter to terminate ... " dummy_userinput 

...並把它傳遞給測試:

/var/www/angular-phonecat$ export CHROME_BIN="/var/www/angular-phonecat/dummy.sh" && npm test 

它以某種方式工作,但虛擬鉻沒有給出我懷疑的正確答案:

INFO [karma]: Karma v0.10.10 server started at http://localhost:9876/ 
INFO [launcher]: Starting browser Chrome 
INFO [Chrome 34.0.1847 (Windows 7)]: Connected on socket Ri4I_SRpM8UA1q_Kq6V6 
WARN [launcher]: Chrome have not captured in 60000 ms, killing. 
INFO [launcher]: Trying to start Chrome again. 
WARN [launcher]: Chrome have not captured in 60000 ms, killing. 
INFO [launcher]: Trying to start Chrome again. 
WARN [launcher]: Chrome have not captured in 60000 ms, killing. 
+0

卡瑪phantomjs – mpm

+0

@mpm謝謝。 karma-phantomjs是一種替代方式,還是更深入研究角手機?我現在正在觀看視頻,所以karma-phantomjs使用真正的webkit,而角度phonecat業力只使用javascript單元測試javascript?我不確定。 –

+0

我發現了同樣的問題,但我實際上從我的無頭debian安裝谷歌庫中安裝了google-chrome-stable。我仍然一再得到錯誤。
INFO [啓動器]:試圖啓動Chrome [[again(2/2)]] 錯誤[啓動器]:無法啓動Chrome 錯誤[啓動器]:Chrome失敗2次(無法啓動)。放棄。 我們是否應該假設您無法在無頭服務器上測試Angular應用程序?似乎令人懷疑,但我很樂意從經驗豐富的人那裏得到澄清。 – mightypile

回答

2

PhantomJS就是爲了這個目的。從PhantomJS網站:PhantomJS的

的主要用途之一是網絡 應用無頭測試。它適用於一般基於命令行的測試, 內預先提交鉤子,並作爲連續集成 系統的一部分。

在你的果報conf.js,設置如下:

browsers: ['PhantomJS'] 
+0

我跑到相同的問題,請參閱修復的詳細答案:http://stackoverflow.com/questions/39005993/cannot-start-chrome-cannot-start-firefox-errors-with-karma-in-vagrant-箱ubun –

相關問題