How do I test an externally served app using Testacular + AngularJS

社会主义新天地 提交于 2019-12-05 03:24:59

问题


I have an app running on http://localhost:6543 - it's a Pyramid app.

  • This app serves the AngularJS app at /
  • This app uses socket.io itself

The question is: is it possible to test that application using those tools ?

I have this in my scenario.js file:

beforeEach(function() {
   browser().navigateTo('http://localhost:6543/');
});

but the moment I launch testacular (with run or start), I get this error message:

Chrome 23.0 registration: should delete all cookies when user clicks on "remove all" button FAILED
browser navigate to 'http://localhost:6543/'
/home/abourget/myapp/jstests/scenarios/registration_scenario.js:9:5: Sandbox Error: Application document not accessible.

so I understand the browser doesn't give access to the iframe's document, because it'd be some Cross-Origin violation.

What I tried:

  • Proxying to my app using the Testacular web server (with the proxies option), but / would conflict with Testacular's own serving of its framework. Also, both apps would eventually try to use /socket.io and that would conflict also.
  • Doing the reverse (tweaking my app to proxy to Testacular's server), but then, we'd get the same issues with /socket.io.

Thanks for these great tools, btw!


回答1:


Instead of having

beforeEach(function() {
    browser().navigateTo('http://localhost:6543/');
});

change this to

beforeEach(function() {
    browser().navigateTo('/');
});

and then in your testacular-e2e.conf.js file add:

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

You might still have other issues, but I can reproduce the "Sandbox Error: Application document not accessible." message with just the Pyramid Hello World App and this configuration problem.




回答2:


We had a similar problem, and had already proxies and navigateTo('/'). We needed to add some urlRoot to avoid conflicts when loading socket.io. We simply added '/e2e' and that was enough to solve the conflict. Actually, there was a warning message when running testacular for this issue.



来源:https://stackoverflow.com/questions/13631360/how-do-i-test-an-externally-served-app-using-testacular-angularjs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!