2013-05-28 326 views
3

我使用npm在Mac OS X 10.8.3上設置了標準yeoman /角度安裝。我使用yo生成器創建了一個新的角度項目。我通過npm install -g phantomjs安裝了phantomjs。我將karma配置爲單獨使用phantomjs(所有其他瀏覽器均正常工作)。當使用grunt test運行測試時,即使設置了非常長的超時(50000ms),phantomjs也不會捕獲。這是日誌輸出:phantomjs不捕獲

Running "karma:unit" (karma) task 
DEBUG [reporter]: Using reporter "progress". 
INFO [karma]: Karma server started at http://localhost:8080/ 
INFO [launcher]: Starting browser PhantomJS 
DEBUG [launcher]: Creating temp dir at /var/folders/6j/gz50dm2d3xv1hnz7s1t4lhn40000gp/T/testacular-79891032 
DEBUG [launcher]: /usr/local/bin/phantomjs /var/folders/6j/gz50dm2d3xv1hnz7s1t4lhn40000gp/T/testacular-79891032/capture.js 
WARN [watcher]: Pattern "/Users/alexanderwalter/Development/angularSeed/test/mock/**/*.js" does not match any file. 
DEBUG [watcher]: Resolved files: 
    /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/adapter/lib/jasmine.js 
    /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/adapter/jasmine.js 
    /Users/alexanderwalter/Development/angularSeed/app/components/angular/angular.js 
    /Users/alexanderwalter/Development/angularSeed/app/components/angular-mocks/angular-mocks.js 
    /Users/alexanderwalter/Development/angularSeed/app/scripts/app.js 
    /Users/alexanderwalter/Development/angularSeed/app/scripts/controllers/add.js 
    /Users/alexanderwalter/Development/angularSeed/app/scripts/controllers/main.js 
    /Users/alexanderwalter/Development/angularSeed/test/spec/controllers/add.js 
    /Users/alexanderwalter/Development/angularSeed/test/spec/controllers/main.js 
DEBUG [web server]: serving: /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/static/client.html 
DEBUG [web server]: serving: /Users/alexanderwalter/Development/angularSeed/node_modules/grunt-karma/node_modules/karma/static/testacular.js 
DEBUG [karma]: New browser has connected on socket wxBffi5IEZn9zQvoTm0J 
WARN [launcher]: PhantomJS have not captured in 50000 ms, killing. 
DEBUG [launcher]: Process PhantomJS exitted with code 1 
ERROR [launcher]: Cannot start PhantomJS 

正如我所說的,它適用於所有其他瀏覽器。如果我將一個簡單的測試腳本傳遞給控制檯,那麼Phantomjs也可以工作。

回答

1

如果您想要使用節點0.10.11,代理選項適用於我(Mac 10.6.8,Karma 0.8.5和節點0.10.11或0.10.7。節點0.10.8/9/10沒有工作。)。

裏面的karma.conf.js文件:

proxies = { 
'/': 'http://localhost:9000' 
}; 
urlRoot = '/__unit/'; 

裏面的果報e2e.conf.js文件:

proxies = { 
'/': 'http://localhost:9000' 
}; 
urlRoot = '/__e2e/'; 
0

我升級到Node.js的最新穩定版本這爲我解決了它。目前v.10.20。