elixir-wallaby/wallaby

refute_has doesn't block (for async code)

jonleighton opened this issue · 1 comments

I wrote a test like this:

session
|> refute_has(css(".my-element"))

The element is becomes hidden via JS executing on the page.

My expectation was that if the element was present when refute_has first runs, it would wait for the async timeout and keep testing the DOM before raising an error. This turns out not to be true, which lead to flakey test failures.

We can do this instead:

session
|> assert_has(css(".my-element", count: 0))

But I find the behaviour of refute_has surprising. Is this deliberate? If not, perhaps it can be changed?

I believe it is deliberate, but it was written before my time. I think there has been discussion to deprecate the function entirely in favor of the method you provided, but I believe that discussion is all it's been.