2013-05-28 283 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。