In a LiveView test, how can I get the full page HTML after the initial render? The Phoenix.LiveViewTest.html#live/2
function returns the full page HTML, but then after some updates happen and I pass the Phoenix.LiveViewTest.View
struct to Phoenix.LiveViewTest.html#render/1
, I only get the HTML of this live view, no layouts.
Here’s a code snippet to show what I mean:
test "deletes user in listing", %{conn: conn, user: user} do
{:ok, index_live, html} = live(conn, ~p"/users")
# includes full page HTML, with all the layouts
dbg(html)
assert index_live |> element("#users-#{user.id} a", "Delete") |> render_click()
# only includes this live view's HTML, no layouts - how can I get the full page HTML here, after the update?
dbg(render(index_live))
end
I would like the full page HTML after updates so that I could send it to an HTML validator, which unfortunately only supports validating full documents, not fragments. But even if it supported validating fragments, there can still be HTML bugs that cannot be caught when validating a fragment only, like invalid tag nesting or referencing not existent elements in for
and aria-labelledby
and similar attributes, so having the full document available would be ideal.