Skip to content

Instantly share code, notes, and snippets.

@herminiotorres
Forked from mcrumm/page_live_test.exs
Created February 8, 2021 22:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save herminiotorres/3e4cecec75441af6bb40b45a95aff74b to your computer and use it in GitHub Desktop.
Save herminiotorres/3e4cecec75441af6bb40b45a95aff74b to your computer and use it in GitHub Desktop.
LiveView artifacts
defmodule MyAppWeb.PageLiveTest do
use MyAppWeb.ConnCase
import Phoenix.LiveViewTest
@tag :tmp_dir
test "disconnected and connected render", %{conn: conn, tmp_dir: tmp_dir} do
{:ok, page_live, disconnected_html} = live(conn, "/")
assert disconnected_html =~ "Welcome to Phoenix!"
assert page_live
|> open_browser(&File.copy!(&1, Path.join([tmp_dir, "welcome.html"])))
|> render() =~ "Welcome to Phoenix!"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment