Skip to content

Instantly share code, notes, and snippets.

@mrjoelkemp
Created September 16, 2020 19:18
Show Gist options
  • Save mrjoelkemp/484fbbfec1e6d59d7a61203a20db8dd0 to your computer and use it in GitHub Desktop.
Save mrjoelkemp/484fbbfec1e6d59d7a61203a20db8dd0 to your computer and use it in GitHub Desktop.
defmodule MyViewTest do
use MyAppWeb.ConnCase
import Phoenix.LiveViewTest
import Mock
require MyView
require MyDataFetcher
test "it renders the fetched data", %{conn: conn} do
response = "Hello There"
with_mock MyDataFetcher,
fetch: fn -> response end do
{:ok, view, _html} = live_isolated(conn, MyView)
assert render(view) =~ response
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment