-
I'm trying to use Svelte to create a simple reactive component. The component loads data from an api server I have a simple vitest that renders the component and verifies the value of the html element. However while running under vitest the
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
The issue #222 contains information about that absence of |
Beta Was this translation helpful? Give feedback.
-
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, 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 |
Beta Was this translation helpful? Give feedback.
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