在AngularJS教程中执行测试时出错,步骤3

时间:2013-04-05 14:54:36

标签: angularjs karma-runner

尝试在角度教程(http://docs.angularjs.org/tutorial/step_03)中运行端到端测试时,我得到以下内容...

我做了“git checkout -f step-3”所以它直接来自回购......

[2013-04-05 07:17:07.774] [WARN] config - "/" is proxied, you should probably change urlRoot to avoid conflicts
INFO [testacular]: Testacular server started at http://localhost:9876/
INFO [launcher]: Starting browser Chrome
INFO [Chrome 26.0 (Mac)]: Connected on socket id CamYxe8MuPk52Agq6g5L
WARN [proxy]: failed to proxy /app/index.html (Error: connect ECONNREFUSED)
WARN [proxy]: failed to proxy /app/index.html (Error: connect ECONNREFUSED)

我在Rails应用程序中运行应用程序,该应用程序由WEBrick在端口3000上提供服务。 所以我将testacula配置更改为...

proxies = {
'/': 'http://localhost:3000/'
};

...然后测试运行但

失败
Chrome 26.0 (Mac) PhoneCat App Phone list view should filter the phone list as user types into the search box FAILED
expect repeater '.phones li' count toBe 3
/Users/paul/rails_projects/angularjs/public/angular-phonecat/test/e2e/scenarios.js:15:7: expected 3 but was 0

所以它似乎没有正确导航到页面。 有人有什么想法吗?

干杯

3 个答案:

答案 0 :(得分:4)

将angular-phonecat / config / testacular-e2e.conf.js代理更新为:

proxies = {
  '/': 'http://localhost:3000/angular-phonecat/'
};

angular-phonecat / test / e2e / scenarios.js中的测试预计能够达到:

http://localhost:3000/app/index.html  

将代理更新为上述配置将解决此问题(或者您可以将所有文件从/ Users / paul / rails_projects / angularjs / public / angular-phonecat / *直接移动到您的公共文件夹中)

答案 1 :(得分:1)

正如克里斯所说,(我提出了他的意见)

我正在运行MAMP所以我不得不将其更改为使用端口:80 / angular-phonecat

答案 2 :(得分:1)

如果您只是运行scripts / web-server.js,那么只需运行服务器:

→ ./scripts/web-server.js 
Http Server running at http://localhost:8000/

请注意 8000 是正确的端口并更新e2e配置文件:

// config/karma-e2e.conf.js

proxies: {
  '/': 'http://localhost:8000/' //was :3000
}

现在运行e2e测试,应该没问题:

→ karma start config/karma-e2e.conf.js