I've got a Web application that continuously polls for data from the server using Ajax requests. I would like to implement an integration test for it using zombie.js.
What I am trying to do is to wait until the Ajax poll loop receives data from the server. The data should be received after 20 seconds, so I use browser.wait(done, callback)
to check if the data is there, and set waitFor
to a maximum timeout of one minute.
However, browser.wait()
always returns almost immediately, even if my done
callback returns false.
In the zombie API documentation, I read the following about browser.wait()
:
... it can't wait forever, especially not for timers that may fire repeatedly (e.g. checking page state, long polling).
I guess that's the reason for the behavior I see, but I don't really understand what's going on. Why can't I wait for one minute until my poll loop receives data from the server? Why can't browser.wait()
wait for timers that may fire repeatedly? What do I need to do to implement my test?
waitFor
, right? I speak of experience ;) Also, don't forget aboutmaxWait
. – Stenophylloussocket.io
would be an excellent alternative – Nelson