How do I test an externally served app using Testacular + AngularJS(如何使用 Testacular + AngularJS 测试外部服务的应用程序)
问题描述
我有一个在 http://localhost:6543
上运行的应用程序 - 这是一个 Pyramid 应用程序.
I have an app running on http://localhost:6543
- it's a Pyramid app.
- 此应用在/处为 AngularJS 应用提供服务
- 此应用使用 socket.io 本身
问题是:是否可以使用这些工具测试该应用程序?
我的 scenario.js
文件中有这个:
I have this in my scenario.js
file:
beforeEach(function() {
browser().navigateTo('http://localhost:6543/');
});
但当我启动 testacular(使用 run
或 start
)时,我收到以下错误消息:
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 网络服务器(使用
proxies
选项)代理到我的应用程序,但/
会与 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/'
};
您可能还有其他问题,但我可以重现沙盒错误:无法访问应用程序文档".仅包含 Pyramid Hello World App 和此配置问题的消息.
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 测试外部服务的应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何使用 Testacular + AngularJS 测试外部服务的应用


- 为什么我的页面无法在 Github 上加载? 2022-01-01
- 在不使用循环的情况下查找数字数组中的一项 2022-01-01
- 如何显示带有换行符的文本标签? 2022-01-01
- 我不能使用 json 使用 react 向我的 web api 发出 Post 请求 2022-01-01
- 是否可以将标志传递给 Gulp 以使其以不同的方式 2022-01-01
- 使用 iframe URL 的 jQuery UI 对话框 2022-01-01
- 如何向 ipc 渲染器发送添加回调 2022-01-01
- 从原点悬停时触发 translateY() 2022-01-01
- 如何调试 CSS/Javascript 悬停问题 2022-01-01
- 为什么悬停在委托事件处理程序中不起作用? 2022-01-01