Retry for Wallaby or ExUnit

Currently I’m developing browser automated tests but sometimes they are flaky so I want to add retry to those tests, Idk if there is an easy way to add retry to a project with Wallaby and ExUnit by configuration or if there is an library out there. Thanks

We have this for tests when data comes in async from another process.

defmodule TimeHelper do
  def wait_until(fun), do: wait_until(1_000, fun)

  def wait_until(0, fun), do: fun.()

  def wait_until(timeout, fun) do
    try do
      fun.()
    rescue
      ExUnit.AssertionError ->
        :timer.sleep(10)
        wait_until(max(0, timeout - 10), fun)
    end
  end
end

import TimeHelper

test "something async", %{view: view} do
  # click link
  wait_until(fn ->
    # assert that content changes
    assert render(view) =~ "Some new data"
  end)
end
2 Likes

Thanks, I think this can work