3 ms·
Does this work well with tests? For instance, if you click a button in a test, do you need to do something special to ensure the async update has happened befor
by ramchip 3y ago
Does this work well with tests? For instance, if you click a button in a test, do you need to do something special to ensure the async update has happened before checking assertions on the HTML contents?
- msmithstubbs 3y agoYes, LiveViewTest (a module included in Phoenix LiveView) supports testing connected mounts. You can write a test that just fetches the disconnected state, and then upgrades it to a connected state (see https://hexdocs.pm/phoenix_live_view/Phoenix.LiveViewTest.html#live/2 https://hexdocs.pm/phoenix_live_view/Phoenix.LiveViewTest.ht...). If you want to test the result of a button click there's support for that, too, with things like `render_click`.
- ramchip 3y agoI mean for async assigns specifically. I did something like this in the past and had some troubles with render_click returning the html before the async update completes.