是否有AngularJS茉莉花测试的wait()的功能? [英] Is there any wait() function for AngularJS Jasmine test?

查看:197
本文介绍了是否有AngularJS茉莉花测试的wait()的功能?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我创建了一个弹出,它会首先点击开将关闭在第二次点击。然而,做测试时,我面临的问题。第二次点击不关闭弹出。而且我发现,这个问题是因为在第一次单击弹出屏幕还尚未出现,这就是为什么第二次点击不关闭弹出。于是,我决定把点击之间的延迟。关于如何实现的延迟任何想法?

 描述('弹出',函数(){
            它(应该关闭的第二次点击功能(){
                compileDirective(400,'点击','真');
                element.triggerHandler('点击');
                waitttttttt(1000); //等待功能这里之前继续执行下一行
                element.triggerHandler('点击');
                范围$摘要()。
                timeout.flush();
                期待($('sidepopright。')的长度。).toBe(0);
                element.remove();
                $(。sidepopright),删除()。
            });
      });


解决方案

您需要的是 browser.waitForAngular();

 描述('弹出',函数(){
            它(应该关闭的第二次点击功能(){
                compileDirective(400,'点击','真');
                element.triggerHandler('点击');
                browser.waitForAngular(); //等待功能这里之前继续执行下一行
                element.triggerHandler('点击');
                范围$摘要()。
                timeout.flush();
                期待($('sidepopright。')的长度。).toBe(0);
                element.remove();
                $(。sidepopright),删除()。
            });
      });

browser.waitForAngular();会等到它得到充分反应到前面

I created a popup, it will open on first click and will close on second click. However, I faced problem when do testing. The second click doesn't close the popup. And I found out that the problem is because during the first click the popup haven't appeared in the screen yet, that's why the second click doesn't close the popup. So, I decide to put a delay between the clicks. Any idea on how to implement the delay?

describe('Popup', function(){
            it("Should close on second click", function(){
                compileDirective(400,'click','true');  
                element.triggerHandler('click');
                waitttttttt(1000); // Wait function here before proceed to next line
                element.triggerHandler('click');
                scope.$digest();
                timeout.flush();
                expect($('.sidepopright').length).toBe(0);
                element.remove();
                $(".sidepopright").remove();
            });
      });

解决方案

what you need is browser.waitForAngular();

describe('Popup', function(){
            it("Should close on second click", function(){
                compileDirective(400,'click','true');  
                element.triggerHandler('click');
                browser.waitForAngular(); // Wait function here before proceed to next line
                element.triggerHandler('click');
                scope.$digest();
                timeout.flush();
                expect($('.sidepopright').length).toBe(0);
                element.remove();
                $(".sidepopright").remove();
            });
      });

browser.waitForAngular(); will wait till it gets the full response to the front

这篇关于是否有AngularJS茉莉花测试的wait()的功能?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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