噶端到端测试:如何知道什么时候该DOM是准备好了? [英] Karma e2e testing: how to know when the DOM is ready?

查看:184
本文介绍了噶端到端测试:如何知道什么时候该DOM是准备好了?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我写了一些端到端测试,到现在为止我一直在使用睡眠(X)函数来等待ajax调用。

I'm writing some e2e tests and up until now I have been using the sleep(x) function to wait for ajax calls.

这是不是很有效,我必须估计值,以等待测试,如果我设置太大的值,那么我的测试正在这时就需要更多的时间。

This is not very efficient as I must estimate the value to wait for testing and if I set too big a value then my tests are taking much more time then needed.

是否有一个ajax通话时间睡觉的方式吗?或者至少重定向到不同的页面时的方式为DOM被加载时睡觉?

Is there a way to sleep for an ajax call duration? or at least when redirecting to a different page a way to sleep for the time the DOM is loaded?

推荐答案

如果你做角情景亚军和因果报应端到端的测试,你不必担心这一点。该框架HANDELS这一切都为您服务。如果你有一个按钮,将导致你的应用程序发送一个AJAX请求和响应改变的东西在DOM中,你可以简单地写你的测试是这样的:

If you do e2e testing with angular scenario runner and karma you do not need to worry about this. The framework handels all this for you. If you have a button that will cause your application to send an AJAX request and on response change something in the DOM, you can simply write your test like this:

element('#mybutton').click();
expect('...'); //Test that checks that the DOM has changed as excpected.

只要你使用全角出

,这将正常工作。

As long as you use angular full out, this will work.

这篇关于噶端到端测试:如何知道什么时候该DOM是准备好了?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆