Closed MathiasWP closed 3 months ago
I don't like writing tests 😅 In all seriousness, I do agree it is a necessary evil. Do you have a suggestion? SvelteKit suggests Playwright since some time now but I haven't used it before myself.
There's been some recent discussion on twitter about which approach to take when testing large React apps (e2e vs unit, etc). That discussion led me to do more research and I came across the Prefer Integration Tests? Think twice article that dives deep into the topic. I suggest you to give it a read if you are unsure about what approach to take. Either way, Johnny Magrippis recently uploaded two videos about integrating SvelteKit with Vitest and with Playwright that could be useful for you.
@buhodev Thanks, I'll check these links out
I can begin working on a test-setup, i'll create a test branch!
Great! Before you take up all the effort, can you elaborate a little bit on the plan? :)
Looking for finding the minimal required setup to setup tests.
I'm thinking a folder structure like this
- test /
- action
- store
- ...etc
We could define all the tests within this folder, and I'm thinking about using Playwright for svelte-stuff, and Vitest for everything else. Thoughts?
OK! 👍 Though I'm currently not even sure sure how much we would need Playwright. As the utilities are designed to be as standalone as possible, maybe simply some unit tests per action, etc. with Vitest will suffice?
OK! 👍 Though I'm currently not even sure sure how much we would need Playwright. As the utilities are designed to be as standalone as possible, maybe simply some unit tests per action, etc. with Vitest will suffice?
The difficult thing i that there is no good way to run unit tests with Vitest. I tried with @testing-library/svelte
, but they don't have a good api for mocking things like clicks and keyboard-events. Playwright has a lot of that, so it makes it much easier to test things like outside click and clipboard stuff.
Ah I see. True, now that I think about it would indeed be much easier to test those things in application context. :) I'll get myself up to speed with it in the meantime; let me know how it goes!
Definitely something that should be added as early as possible, will make the library a lot more appealing, and it's a lot easier beginning with it from the get-go instead of having it as a technical debt. Also makes it easier for other people to contribute/fix issues.