Closed Bastes closed 2 years ago
Ok, tried importing Phoenix.LiveViewTest
hoping it solves the problem, with:
defmodule MyApp.PageLiveSpec do
use ESpec.Phoenix, controller: MyApp.PageLive, async: false
import Phoenix.LiveViewTest
describe "GET /" do
it "displays the page" do
{:ok, page_live, disconnected_html} = live(build_conn, "/")
assert disconnected_html =~ "My App's Title"
assert render(page_live) =~ "My App's Title"
end
end
end
Got:
spec/my_app/live/page_live_spec.exs:7
** (ArgumentError) fetch_test_supervisor!/0 can only be invoked from the test process
(phoenix_live_view 0.15.7) lib/phoenix_live_view/test/live_view_test.ex:359: Phoenix.LiveViewTest.fetch_test_supervisor!/0
(phoenix_live_view 0.15.7) lib/phoenix_live_view/test/live_view_test.ex:301: Phoenix.LiveViewTest.connect_from_static_token/2
spec/my_app/live/page_live_spec.exs:9: MyApp.PageLiveSpec.example_displays_the_page_cjkvbieutrfosynqzmxghldwap/1
(espec 1.8.3) lib/espec/example_runner.ex:86: ESpec.ExampleRunner.try_run/3
(espec 1.8.3) lib/espec/example_runner.ex:56: ESpec.ExampleRunner.run_example/2
(elixir 1.11.3) lib/task/supervised.ex:90: Task.Supervised.invoke_mfa/2
(elixir 1.11.3) lib/task/supervised.ex:35: Task.Supervised.reply/5
(stdlib 3.14) proc_lib.erl:226: :proc_lib.init_p_do_apply/3
So, no luck just using the original function :/
Hi,
My team's considering espec to build a new phoenix project, one that will use liveview heavily and therefore we would like to test those liveviews.
Searching on how to do the plumbing between espec and phoenix, I only found this project, which installs nicely, but I can't find documentation about testing liveviews in your
README.md
, and when I try to just translate a simple exunit live view test into what I assume should be the way to to those with your package, here's what I get:So... I'm kind of wondering if there is live_view support in this package :sweat_smile: ; is there? If there is, what am I missing? If not, will there be sometimes in the future?
Thanks in advance :)