sveltesociety.dev icon indicating copy to clipboard operation
sveltesociety.dev copied to clipboard

Slots testing recipe idea

Open benmccann opened this issue 4 years ago • 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: https://github.com/bahmutov/cypress-svelte-unit-test/issues/251#issuecomment-763384835. I then found one of the Svelte maintainers doing the same thing here: https://github.com/sveltejs/svelte/pull/4296#issuecomment-701731455

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

benmccann avatar Sep 05 '21 03:09 benmccann

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.

kevmodrome avatar Sep 06 '21 09:09 kevmodrome

I think this needs to be revisited.

ibrahimqasim avatar Oct 06 '23 20:10 ibrahimqasim