phoenixframework / phoenix_live_view

Rich, real-time user experiences with server-rendered HTML
https://hex.pm/packages/phoenix_live_view
MIT License
6.23k stars 934 forks source link

Implicitly, testing a live view that uses `assign_async` or `start_async` means you should always use `render_async` in every test #3481

Closed dersmon closed 1 week ago

dersmon commented 4 weeks ago

This might be just a documentation issue.

Environment

Actual behavior

I have some live views that load additional information using assign_async. When testing the primary functionality of the view (stuff that is not relying on assing_async), I experienced error messages like the following:

[error] MyXQL.Connection (#PID<0.308.0>) disconnected: ** (DBConnection.ConnectionError) client #PID<0.794.0> exited

I can fix this by adding a (otherwise superfluous) render_async at the end of every test.

Expected behavior

If you deem this the most practical solution I'd be happy to add an appropriate line to the docs for assign_async or start_async. I was just wondering if there is a way to make tests wait for async assigns by default?

dersmon commented 4 weeks ago

Basically this could be rephrased a bit: https://github.com/phoenixframework/phoenix_live_view/pull/3449

SteffenDE commented 1 week ago

@dersmon there's no way to make it wait by default, so I'd say please go ahead and create a PR for the docs :)