Skip to content

Proposal: Make it possible to change interval wait time if timeout is less than 100ms #281

@nicanor

Description

@nicanor

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! 🙌

Metadata

Metadata

Assignees

No one assigned

    Labels

    let's get a PR goingThe idea seems good. Happy to review a PR

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions