I think scala testing libraries has an operator for tests that checks some condition eventuallt evaluates to true (with an implicit timeout). Is there an equivalent function in a common elixir testing utility library?
There’s nothing in core ExUnit. There are few third party libraries or you can do:
# try 10 times every 100ms
assert Stream.interval(100)
|> Stream.take(10)
|> Enum.any?(fn _ -> …test end)
I think one reason this is less common in Elixir is that a lot of things you’d wait for are better accomplished by waiting to receive a message that either is the check or indicates that you can now check instead of polling. In other words if you perform a background task instead of polling to see if the task is complete, monitoring the background process and waiting for an exit message is probably better.
I’ve used ExUnit.Assertions — ExUnit v1.12.3 (assert_receive/3) for times where I’ve needed to do this
I don’t follow this completely. It may or may not be applicable to my situation. I’m trying to test some code under test that is launching asynchronous work which is writing to a log. I eventually want to see the log message in the log file.