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

Test server-rendered components #418

Open
theetrain opened this issue Dec 12, 2024 · 1 comment
Open

Test server-rendered components #418

theetrain opened this issue Dec 12, 2024 · 1 comment

Comments

@theetrain
Copy link

Is it possible today to test a server-rendered component? My understanding is render will return a mounted component with all initial JS ran (top-level <script>, effects and use: actions).

If not, it would be helpful to be able to test a server-rendered component easily; maybe as part of render results: https://testing-library.com/docs/svelte-testing-library/api/#render-results

@mcous
Copy link
Collaborator

mcous commented Dec 12, 2024

At the moment, this library is very much concerned with testing the client-side behavior of components. It's difficult for client rendering and server rendering to co-exist in the same suite/Vitest workspace.

Additionally, most of the utility of this library involves setting up the testing-library queries in a DOM environment and cleaning up said DOM. Without the DOM, this library doesn't add much on top of calling Svelte's mount function.

You may want to explore using svelte/server directly in your tests. I'd be curious to hear how you go with it just in case there is interesting / helpful stuff we could wrap! The Vitest setup for such a thing might be a little involved, so happy to help out as needed

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

2 participants