caslu
Hello everyone
. So i was doing some searches about LiveSvelte project, an awesome project by the way, but i had a question though: What about testing?
So live view comes with a bunch of macros for test, you can assert that a view rendered offline or connected, assert that after click event the view was redirect and much more, but when using live svelte your ui is driven mostly on “Svelte side”, so how would i test the code? Should i just ignore this live view ready to go test infrastructure and do svelte tests ? Have you guys had such experience with this or even know some example project that uses LiveSvelte and has tests?
Hope it was clear enough, thanks mates
![]()
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
I’m seeing that a list inside a Kino.DataTable will be interpreted as a charlist, even if the Kino.configure() is set to charlists: :as_l...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
Hi, I’ve just set up an application with ash_authentication. There is only magic link strategy for now, so there is no confirmation add o...
New
If a change or preparation module uses Ash.Changeset.get_argument/2 or Ash.Query.get_argument/2 (or any of the other get_argument functio...
New
Other Trending Topics
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
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
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 6- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
ravecat
The topic seems important, I was surprised no one in the repository continued this discussion How to test components using live_svelte · woutdp/live_svelte · Discussion #160 · GitHub. Completed with the error examples
I would be glad if someone could share some advice
ravecat
I’m copying here my response from the discussion in the live_svelte repository
I migrated a part of LiveView to live_svelte and encountered errors in tests with LiveViewTest. Can someone share an approach to testing? testing is the biggest challenge for me so far
I made an example that shows the error
Branch
Run
During development everything is great and the transition was almost painless, however when testing I get an error (Attempting to reconnect)
ravecat
just migrated the test environment for the client side to wallaby, keep it for the history here
Jskalc
Hi, I’m the creator of LiveVue library heavily inspired by LiveSvelte.
I can add 2cents from my side, there are two valid approaches to testing:
Approach 2 is kinda obvious, and gives you the most value but with significant initial investment.
But, I wanted to explain a bit more about 1). In LiveSvelte props are rendered simply in
data-propsattribute of a LiveSvelte root element. So it should be fairly trivial to decode them. Something along the lines (extracted from LiveVue version):Then, you can make assertions on these props, in the same way as you’d be testing a normal LiveView application.
This simple approach let’s you test all the updates inside the Live process, and check if rendered props are what you’d expect. Obviously it’s not checking actual rendered HTML, event handlers etc, but often it’s a good tradeoff.
Maybe @woutdp would be willing to incorporate such a helper inside LiveSvelte as well?
ravecat
Thanks for the comment, but I expect the testing to just test the actual html and handlers. Tying tests to framemork attributes is a so-so idea in my opinion
Jskalc
Well, it’s basically a valid way to get up-to-date props of your svelte component. All the rest happens on the client-side.
It already allows you to test your whole view - mounting, handling various events and asserting on props passed down to your svelte component. If you’ll throw SSR to the mix you’ll be able to assert on rendered HTML as well. For some developers this might be a good tradeoff between complexity and brittleness of headless browser tests.
But yeah, that way you won’t be able to test eg button clicks or client-side state. For that you have to use Wallaby or similar, as you’re already doing.
Regarding your issue with “Attempting to reconnect” - this is always rendered by your
flash_groupcore component, just not visible. Then client-side phoenix code shows and hides it on websocket connect and disconnect, like this:In other words, it’s always present in HTML returned by your view, as long as you use
flash_groupin yourapp.html.heex. Hope this helps