News for hackers. Stuff that matters.
Re:Comparing Svelte and React by dceddia on Wednesday March 24, 2021 @06:45PM (#26573981)
There’s svelte-testing-library [0] which follows the same approach as the React flavor. It emphasizes testing the app “as the user would use it”, which boils down to rendering components and inspecting the DOM. They intentionally don’t give you visibility into the internal state of the component, which can be weird to get used to if you’re used to doing things like “click the button; assert that state isClicked became true”, but it tends to result in less brittle tests.

0: https://testing-library.com/docs/svelte-testing-library/intr...

Re:Comparing Svelte and React by Vinnl on Thursday March 25, 2021 @03:45AM (#26577407)
Thanks, that looks pretty good, and testing-library is excellent. I couldn't find it in the docs, but do you know how this "renders" the Svelte components - in memory using e.g. jsdom, or by firing up a full-fledged browser? (The former would be highly preferable.)
Re:Comparing Svelte and React by dceddia on Thursday March 25, 2021 @08:37AM (#26579451)
Testing-library uses jsdom across the board, as far as I know. It might support running in a full browser too but I haven’t used it that way.

For end-to-end tests with a real browser, Cypress is a good option.

Re:Comparing Svelte and React by Vinnl on Thursday March 25, 2021 @01:01PM (#26582664)
Cool, sounds like it should be in a usable state then.