Skip to content

Unit Test Svelte Component { #if } #283

Answered by mcous
feelinglovelynow asked this question in Q&A
Discussion options

You must be logged in to vote

It looks like your question isn't about how to test an {#if} block, but rather how to get the coverage report to show the {#if} branch as covered when you have tested it.

Honestly, you're going to be at the mercy of the Svelte compiler and its source maps here; getting accurate coverage reporting of transpiled languages is difficult at the best of times. There's nothing this library here does to affect it: we just mount the component using the API provided to us by Svelte.

The best advice I can give you here is: try to worry less about your coverage stats! All this testing-library stuff is more integration testing than unit testing, because you're always going through the full Svelte runt…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by yanick
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants