Phoenix.LiveViewTest.render_hook
You're seeing just the function
render_hook
, go back to Phoenix.LiveViewTest module for more information.
Sends a hook event to the view or an element and returns the rendered result.
It returns the contents of the whole LiveView or an {:error, redirect}
tuple.
Examples
{:ok, view, html} = live(conn, "/thermo")
assert html =~ "The temp is: 30℉"
assert render_hook(view, :refresh, %{deg: 32}) =~ "The temp is: 32℉"
If you are pushing events from a hook to a component, then you must pass
an element
, created with element/3
, as first argument and it must point
to a single element on the page with a phx-target
attribute in it:
{:ok, view, _html} = live(conn, "/thermo")
assert view
|> element("#thermo-component")
|> render_hook(:refresh, %{deg: 32}) =~ "The temp is: 32℉"