Skip to content

testing svelte component's onMount #243

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

You must be logged in to vote

We traced this to an issue with how Vitest likes to configure its resolution rules: unlike Jest, Vitest will prefer server module bundles - rather than browser bundles - unless specifically configured otherwise. In the server bundle of Svelte, onMount is a no-op.

In the latest setup docs we have included a simple way to configure Vitest to use browser bundles. There's more than one way to configure this, with different tradeoffs. See the thread in #222 for more information

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
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
3 participants