Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add tests #7

Closed
MathiasWP opened this issue Jul 20, 2022 · 9 comments
Closed

Add tests #7

MathiasWP opened this issue Jul 20, 2022 · 9 comments
Milestone

Comments

@MathiasWP
Copy link
Contributor

MathiasWP commented Jul 20, 2022

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.

@nikolai-cc
Copy link
Owner

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.

@buhodev
Copy link
Contributor

buhodev commented Jul 20, 2022

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.

@nikolai-cc nikolai-cc added this to the 1.0 milestone Jul 21, 2022
@nikolai-cc
Copy link
Owner

@buhodev Thanks, I'll check these links out

@MathiasWP
Copy link
Contributor Author

I can begin working on a test-setup, i'll create a test branch!

@nikolai-cc
Copy link
Owner

Great! Before you take up all the effort, can you elaborate a little bit on the plan? :)

@MathiasWP
Copy link
Contributor Author

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?

@nikolai-cc
Copy link
Owner

nikolai-cc commented Jul 21, 2022

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?

@MathiasWP
Copy link
Contributor Author

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.

@nikolai-cc
Copy link
Owner

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants