Skip to content

How to use retry/2 #608

Answered by mhanberg
aidalgol asked this question in Q&A
Jul 22, 2021 · 1 comments · 5 replies

You must be logged in to vote

Can you elaborate a little more on the test scenario?

I am curious as to why you are resorting to using the retry function.

But, the reason why you're test is passing right now is because retry/1 expects the callback to return an ok/error tuple, and retry/1 will then pass that value through, but you aren't asserting on anything. The following would fail your test if the callback passed to retry/1 does not return {:ok, <some value>} within the timeout.

assert {:ok, _session} =
   retry(fn ->
      if current_path(session) == "/" do
        IO.puts("At root")

        {:ok, assert_has(session, Query.css(".notification.is-info"))}
       else
        {:error, :url_not_refreshed}
      end
    

Replies: 1 comment 5 replies

You must be logged in to vote
5 replies
@aidalgol

@mhanberg

@aidalgol

@mhanberg

@aidalgol

Answer selected by aidalgol
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants