Quantcast
Channel: Active questions tagged svelte - Stack Overflow
Viewing all articles
Browse latest Browse all 1541

How to create unit test in Svelte using Vitest?

$
0
0

I have created a skeleton project using Sveltekit. I would like to create unit tests for three different files. One of the first files is the index.js under the src/lib folder:

export function add(a, b) {  return a + b;}

The other two files are a Svelte component. The home page is in the src/routes/+page.svelte file:

<h1>Welcome to SvelteKit</h1><p>Visit <a href="https://kit.svelte.dev">kit.svelte.dev</a> to read the documentation</p>

The about page is in the src/routes/about/+page.svelte file:

<script>  export let foo = 'bar';</script><input type="text" bind:value={foo} /><div>Hi {foo}!</div>

In the About page, there is a property that can be changed by an input field. How to pass values to the component during the unit test?


Viewing all articles
Browse latest Browse all 1541

Trending Articles