简体   繁体   English

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

[英]Error running test in AngularJS tutorial, step-3

I get the following when trying to run the end-to-end test in the angular tutorial ( http://docs.angularjs.org/tutorial/step_03 )... 尝试在角度教程中运行端到端测试时,我得到以下内容( http://docs.angularjs.org/tutorial/step_03 )...

I did "git checkout -f step-3" so it's straight from the repo... 我做了“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)

I'm running the app inside a Rails app, which is being served by WEBrick on port 3000. So I change the testacula config to... 我在Rails应用程序中运行应用程序,该应用程序由WEBrick在端口3000上提供服务。所以我将testacula配置更改为...

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

...then the test runs but fails with ...然后测试运行但失败了

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

So it seems it's not navigating to the page correctly. 所以它似乎没有正确导航到页面。 Anyone have any ideas? 有人有主意吗?

Cheers 干杯

Update your angular-phonecat/config/testacular-e2e.conf.js proxy to this: 将angular-phonecat / config / testacular-e2e.conf.js代理更新为:

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

The tests in angular-phonecat/test/e2e/scenarios.js are expecting to be able to reach: angular-phonecat / test / e2e / scenarios.js中的测试预计能够达到:

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

Updating the proxy to the above configuration will fix this (or you could move all the files from /Users/paul/rails_projects/angularjs/public/angular-phonecat/* directly into your public folder) 将代理更新为上述配置将解决此问题(或者您可以将/ Users / paul / rails_projects / angularjs / public / angular-phonecat / *中的所有文件直接移动到您的公用文件夹中)

As Chris has said, (I upped his comment) 正如克里斯所说,(我提高了他的评论)

I am running MAMP so I had to change it to use port :80/angular-phonecat 我正在运行MAMP所以我不得不改为使用port:80 / angular-phonecat

If you are simply running scripts/web-server.js then just run the server: 如果您只是运行scripts / web-server.js,那么只需运行服务器:

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

Notice that 8000 is the correct port and update the e2e config file: 请注意, 8000是正确的端口并更新e2e配置文件:

// config/karma-e2e.conf.js

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

Now run e2e tests and it should be fine: 现在运行e2e测试,应该没问题:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM