Rubas
Enhancing LiveViewTest API for better async testing
Current Challenge
When testing LiveViews that use assign_async, we can’t really operate on the async data.
-
render_async(view)waits for async operations but only returns the html -
All the other render_* test functions (
render_click,render_patch, etc.) can not be used in combination with async content
Problem
- We can’t use
render_patchand then assert on async data that loads after navigation - We can’t use
render_clickon elements that appear in async-loaded content
…
Solution
I’m not sure yet what the most elegant way to solve this is …
Marked As Solved
LostKobrakai
What’s the problem with just returning HTML? The LV test api is not a functional API. view includes a pid, which is what most apis talk to, so you don’t need to get a new view back everywhere.
1
Last Post!
Rubas
You are right. I missed something here.
This works
# Navigate to appointments list
{:ok, view, _html} = live(conn, ~q"/:locale/user/appointments")
# Navigate to first appointment
render_patch(view, ~q"/:locale/user/appointments/123")
# Wait for async data to load and render
html1 = render_async(view)
# Verify first appointment data
assert html1 =~ "Location One"
assert html1 =~ "123-456"
assert html1 =~ "John Doe"
# Navigate directly to second appointment
render_patch(view, ~q"/:locale/user/appointments/456")
# Wait for async data to load and render
html2 = render_async(view)
# Verify second appointment data
assert html2 =~ "Location Two"
assert html2 =~ "789-012"
assert html2 =~ "Jane Smith"
# Ensure first appointment data is no longer present
refute html2 =~ "Location One"
0
Popular in Proposals: Ideas
IEx is a very powerfull shell and it would be awesome to have all this power integrated inside a code editor. Clojure enables something l...
New
Hello everyone!
Phoenix LiveView v0.18 introduced the special attributes :let, :for and :if. In addition to the :if special attribute, I...
New
Hi Phoenix community!
First off, huge thanks for an amazing framework - Phoenix has been a joy to work with. I have a small UX suggestio...
New
Problem
The cancel_async function is easily overlooked. Since the results of “outdated” tasks are ignored, it’s easy for developers to a...
New
I’ve been messing around with image generation models recently and thought this could be wrapped in a library or people could just use th...
New
In 2026 double submit/session tokens are no longer necessary to prevent against CSRF attacks. Instead, we can use the Sec-Fetch-Site head...
New
Problem
Currently, List.first/2 and List.last/2 return a default value (or nil) when the list is empty. However, there are cases where an...
New
Other popular topics
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible.
total = 10
while total != 0
...
New
I wrote this comment on r/haskell, and it’s not popular there. :wink: But I think I’m on to something…
Haskell reminds me of Java, and e...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
i’m a new one to elixir
which editor can i use
vs code? or atom?
Thanks! :smiley:
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









