svelte-society/sveltesociety.dev

Slots testing recipe idea

benmccann opened this issue · 2 comments

There's a recipe about testing: https://sveltesociety.dev/recipes/testing-and-debugging/unit-testing-svelte-component/

I found another another solution to testing slots here: bahmutov/cypress-svelte-unit-test#251 (comment). I then found one of the Svelte maintainers doing the same thing here: sveltejs/svelte#4296 (comment)

I saw some references to $$slots being private, but that may have only been true in the past because I see it in the docs, so it feels pretty safe to rely on: https://svelte.dev/docs#slots_object

It looks like @kevmodrome originally added this recipe in https://github.com/svelte-society/sveltesociety.dev-legacy/commits/2103aaf7b9e670b7cfb64048664fd2d2d7ac1dd6/src/pages/recipes/testing-and-debugging/authenetication-with-svelte.svx. I haven't done much unit testing of Svelte components, so I'm curious what he thinks about this approach

I didn't write the recipe (I think @pngwn did, though I don't remember exactly) but I think changing the recipe to use the method that Luke suggested there makes sense.

In general I think the recipes need some tidying up and re-writing.

I think this needs to be revisited.