question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Make waiting for event loop implicit or explicit in all cases

See original GitHub issue

Zombie.js does not start to process its event queue until you call browser.wait().

In some browser methods, like click(), this call to wait is implicit, meaning the method calls wait() for you or returns the lazy promise returned by browser.fire(). Then again some browser methods, like fill() ignore the lazy promise returned by browser.fire() and return this. In the latter case you must call browser.wait() in your test code explicitly. This is unexpected and not well documented and leads to confusing test code.

I personally would prefer an implicit approach, so all browser methods emitting events would implicitly run wait() by returning the promise returned by browser.fire(), but either way, all the methods should have the same behaviour.

Issue Analytics

  • State:open
  • Created 7 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
jliuhtonencommented, Jun 9, 2016

Fair enough.

I was referring more to the easiness of constructing a mental model of how Zombie works and how to write (and read) code that triggers DOM events inside it. IMO it would make things easier if there no special cases and exceptions for doing similar things (interacting with the page DOM).

Sure, one can implement a utility that does the waiting or call .wait() always explicitly, but that’s beside the point.

Btw. the way I discovered this was that I tried to implement a waiting assertion that checks periodically whether a given predicate is true or times out with an assertion error after a given period. Using one of the methods that do not wait of course I ended up always timing out, because the event loop was not run at all. After this I read the source and learned that .wait() does more than waiting. I now understand why it is, but it’s still a surprising implementation detail that the event loop does not run by itself and you have to call a method called .wait() (sometimes) to make it run.

The reason I brought this up is that I really like Zombie’s approach to headless browser testing with Node and I hope that it can be made even better in the future. Thanks for your work! 👍

0reactions
assafcommented, Jun 9, 2016

Yes, definitely some people will find it more useful if fill also did a wait, just like some people find it more useful that you can chain multiple fill. Neither of these shortcuts will please everyone, I just find the current API to be the most useful.

You asked about making wait implicit or explicit for all methods. Explicit is already supported: call the method without a callback, then follow up with a call to wait.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Explicit vs Implicit event loop - Google Groups
In practice it means that every test tool creates an event loop, runs test with it and closes the loop after test finishing....
Read more >
Implicit and Explicit Wait in Selenium WebDriver (Types of ...
In this Implicit and Explicit Wait in Selenium WebDriver tutorial we will discuss different types of Selenium WebDriver Waits and navigation ...
Read more >
Experiments in concurrency 3: Event loops | Shalvah's Blog
First, it executes your code, statement-by-statement. Then, if there are any tasks in the task queue (which your code might have added), it ......
Read more >
Implicit versus explicit event tracking: Hits and misses
We decided to pen down our thoughts in this article to help illustrate the hits and misses of implicit versus explicit event tracking....
Read more >
Implicit Versus Explicit Event Tracking: Hits and ... - Amplitude
Also known as codeless event tracking, this type of automatic event collection aims to collect all user interactions within your application. In ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found