Hi , I’ve got liveview page generated by render function like this :
def render(assigns) do
~L"""
<h1 class="page-title">Strategies : <%= @name %> </h1>
<div>
<%= for strategy <- @strategies do %>
<div class="strategy">
<div class="strategy-name"><%= strategy.name %></div>
<div class="strategy-slug"><%= strategy.slug %></div>
</div>
<% end %>
</div>
"""
end
When I try to test it:
{:ok, view, html} = live(conn)
IO.inspect html
I see only : <h1 class="page-title">Strategies : Some Name </h1>
Html body inside “for” loop is not visible (doesn’t exist) .
So I can’t test it not via Hound, Wallaby nor native LiveViewTest . I see only html inside h1 tag.
How to make visible html body inside “for” loop during test ?
Strategies are rendered. I have one liveview page depends on routing :
live “/strategies”, Engine.StrategiesLive , :index
live “/strategies/:category”, Engine.StrategiesLive , :type
In web browser I see whole page , but during testing not.
defmodule SimpleTest do
use MyAppWeb.ConnCase, async: false
import Phoenix.LiveViewTest
test "simple test ", %{conn: conn} do
conn = get(conn, "/strategies")
{:ok, view, html} = live(conn)
IO.inspect html #no html in "for" loop place
end
end