Zombie.js pressButton Long Callback Delay

I tried to figure this out using a bunch of console.logs and still can't figure out why these loads took so long.

So, I have the following code in my beforeEach in my Mocha unit test file.

 browser.fill('email', 'test1@test.com'); browser.fill('password', 'testtest'); browser.pressButton('Login').then(function () { console.log("#100 - "+ new Date().getTime()); done(); }); 

Pressing the button in this case will have several redirects, and then finally display the dashboard page. At the bottom of this html file, I have the following code.

 <script> $(document).ready(function () { console.log("#200 - "+ new Date().getTime()); }); </script> 

So, after running the tests, if after #100 minus the value after #200 will cost about 5000-6000. Since #200 always prints to #100 after about 5-6 seconds.

I don’t understand why after loading the page, it takes another 5-6 seconds for Zombie.js to call this callback function.

Does Zombie.js have some waiting or delay time that I miss after loading the page? What else could cause this 5-6 second delay between loading the page and Zombie.js calling this callback function?

EDIT I now have the same problem, but with 50000ms. And it really adds super fast across all my tests. I still cannot understand why this is happening.

EDIT 2

If I add browser.debug() to my test, it will print the following at the very end. He also prints a lot of other things, but this happens pretty quickly. I think the following problem may be the problem. I just don’t know why this is done or how to fix it.

 zombie Fired setInterval every 5000ms +11ms zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s zombie Fired setInterval every 5000ms +5s 

What causes all zombie Fired setInterval every 5000ms and how to fix it so that it does not accept 55000ms +?

EDIT 3

I also added the following code at the beginning of unit test.

 browser.addListener("setInterval",function (a,b) { console.log("a: "+a); console.log("b: "+b); }); 

After printing each zombie Fired setInterval every 5000ms +5s it also prints the following because of this listener.

 a: function (){var b,c,d;if(b=window.location.href,b!==h){try{d=JSON.stringify({action:"ping",sid:a.utils.getSessionID(),muid:a.utils.getMerchantID(),referrer:h,url:b,title:document.title}),e.contentWindow.postMessage(d,"*")}catch(f){c=f}return h=b}} b: 5000 

a and b match after each of those 11 zombie Fired setInterval every 5000ms . This does not change at all between these 11 times.

I thought the function would help in something, but I still don't understand why this is happening or how to fix it at all.

+8
performance javascript mocha
source share
1 answer

Zombie downloads all resources and processes all events before starting the callback. Instead of using it, click the button , try submitting the form directly and using wait with a terminator callback that will be called after each event. This should show you the reason for the delay:

 browser.document.forms[0].submit(); browser.wait(function(){ //called after each event }, function() { //all events processed }); 

In the API docs:

browser.wait (callback)

browser.wait (terminator, callback)

Handle all events in the queue and call a callback when this is done.

You can use the second form to transfer control before processing all the Events. The terminator can be a number, in which case many events are processed. This may be a function that is called after each event; processing stops when the function returns false.

+1
source share

All Articles