Proposal: Make it possible to change interval wait time if timeout is less than 100ms
Hi German! First, I want to thank you for phoenix_test. It's amazing. I love it.
I would like to know if it would be possible to make the interval wait time configurable.
Right now it is fixed at 100ms.
Some context: I have lots of LiveViews where I use assign_async. And I have been using the assert_has() with timeout option a lot.
I would expect that this assertion never waits for more than 20 milliseconds:
|> assert_has("h1", text: "Some title", timeout: 20)
But that's not the case, it always wait for at least 100ms. Most of my total test time is spent waiting for the interval wait time.
I looked at the source code, and found that any time smaller than 100 will be treated the same
wait_time = interval_wait_time()
new_timeout = max(timeout - wait_time, 0)
I propose that if timeout is less than 100ms, we use that value as the wait time:
wait_time = min(timeout, interval_wait_time())
new_timeout = max(timeout - wait_time, 0)
This change would improve by a lot my test time. I'm more than happy to create a PR. Please let me know if you like this solution or if you prefer a different one, or nothing at all.
Thanks again for the great work! 🙌
@nicanor thanks for opening this issue! It makes sense to me that the timeout would be configurable. I like the default of 100ms, but happy to review a PR that introduces the option to configure it. 🎉