I have a LiveView that starts a GenServer on mount. This GenServer loads data and at some point broadcasts a message to a topic that the LiveView is subscribed to.
How to write tests for this?
test "displays company name", %{conn: conn} do
{:ok, view, html} =
live_isolated(conn, MyLiveView, session: %{"customer_id" => "5013"})
assert html =~ "Company Name"
end
Company Name is rendered after the PubSub message is received. But the live_isolated in the test gives me the html right after mount. So how can I get the new html in the test?
I ran into this same problem and wanted to try your solution, but the funciton wait_until does not seem to be a liveview function… I get an undefined function error.