jc00ke
I’m curious as to what are the latest best practices when testing LiveView components? My app was on an old version straight from Github, before the official 0.x release. I started off by testing my components using mount/3 but that looks to have been deprecated. Having to run through the router might mean authenticating a user, which seems to distract from a more focused “unit” test.
I see now that we’re encouraged to make an actual call through the router to test the disconnected state:
use Phoenix.ConnTest
import Phoenix.LiveViewTest
@endpoint MyEndpoint
test "disconnected and connected mount", %{conn: conn} do
conn = get(conn, "/my-path")
assert html_response(conn, 200) =~ "<h1>My Disconnected View</h1>"
{:ok, view, html} = live(conn)
end
My first question is, what was the motivation for switching from a more direct method of testing (getting the view and html via mount_disconnected/3) to running it through the router?
My next question is: is there still a way to test the disconnected state w/o going through the router?
Thanks for your advice!
Trending in Questions
Other Trending Topics
Latest Phoenix Threads
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ai
- #ecto-query
- #elixirconf-us
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #elixirconf-eu
- #api
- #forms
- #metaprogramming
- #hex










Showing Posts 1 to 1- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
jc00ke
I may have answered my own question: live_isolated/3.