我如何使用Testacular + AngularJS测试外部应用服务 [英] How do I test an externally served app using Testacular + AngularJS
问题描述
我有上运行的应用程序的http://本地主机:6543
- 这是一个金字塔的应用程序
I have an app running on http://localhost:6543
- it's a Pyramid app.
- 这个程序在服务于AngularJS应用程序/
- 这个应用程序使用socket.io本身
现在的问题是:是否有可能使用这些工具来测试该应用程序
我有这在我的 scenario.js
文件:
beforeEach(function() {
browser().navigateTo('http://localhost:6543/');
});
但现在我推出testacular(以运行
或启动
),我得到这个错误信息:
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.
我是这么理解的浏览器不给访问 IFRAME
的文件,因为它会出现一些跨来源冲突。
so I understand the browser doesn't give access to the iframe
's document, because it'd be some Cross-Origin violation.
我试过:
- 代理到使用Testacular Web服务器(使用
代理
选项)我的应用程序,但/
将与冲突Testacular自己的框架,提供服务。另外,这两个应用最终会尝试使用/socket.io
,并且也将发生冲突。 - 在做反向(调整我的应用程序代理Testacular的服务器),但随后,我们会得到相同的问题与
/socket.io
。
- 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!
推荐答案
而不是具有
beforeEach(function() {
browser().navigateTo('http://localhost:6543/');
});
更改为
beforeEach(function() {
browser().navigateTo('/');
});
,然后在testacular-e2e.conf.js文件添加:
and then in your testacular-e2e.conf.js file add:
proxies = {
'/': 'http://localhost:6543/'
};
您可能还有其他的问题,但我可以重现沙箱错误:应用程序文件无法访问消息,只是金字塔的Hello World应用这个配置问题。
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.
这篇关于我如何使用Testacular + AngularJS测试外部应用服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!