phoenix_live_view icon indicating copy to clipboard operation
phoenix_live_view copied to clipboard

Missing `phx-update="stream"` attribute should be detectable and error out in tests

Open srcrip opened this issue 6 months ago • 2 comments

Apologies if I'm missing something and it actually does this already but I'm pretty sure it does not?

There's some things that throw warnings in the JS console when you're using LiveView that have started hard erroring in your tests, such as duplicate IDs, which I think is an amazing feature. To go along with that I think the warning about missing phx-update="stream" is something that sounds to me like should be detectable in tests and should also throw an error at you.

srcrip avatar Jun 22 '25 03:06 srcrip

I see @SteffenDE actually had code to do this: https://github.com/phoenixframework/phoenix_live_view/pull/3645 so that would be amazing if we could!

Also can I add on to this--is there some way we could get the option to make some of these errors even noiser in dev? I'd even like the option to throw an error in Elixir to stop the page altogether. This is a syntax error thats really easy to break and basically totally breaks streams.

srcrip avatar Jun 22 '25 03:06 srcrip

I think I also had code for LiveViewTest somewhere, but I can't find it right now. It's definitely possible.

For making it more visible, I've been thinking more than once that it would be nice to inject some element into the page liveSocket.enableDebug() is true (which is the default for localhost). If you'd see a big red exclamation mark in a corner, that should probably get your attention.

SteffenDE avatar Jul 04 '25 09:07 SteffenDE