You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It is possible to use runes inside your test files. First ensure your bundler knows to route the file through the Svelte compiler before running the test by adding `.svelte` to the filename (e.g `multiplier.svelte.test.js`). After that, you can use runes inside your tests.
49
57
50
58
```js
59
+
// @filename: multiplier.svelte.d.ts
60
+
exportdeclarefunctionmultiplier(fn: () =>number, b:number): { value: number };
61
+
62
+
// @filename: index.js
63
+
// ---cut---
51
64
/// file: multiplier.svelte.test.js
52
65
import { flushSync } from'svelte';
53
66
import { expect, test } from'vitest';
@@ -68,6 +81,11 @@ test('Multiplier', () => {
68
81
If the code being tested uses effects, you need to wrap the test inside `$effect.root`:
69
82
70
83
```js
84
+
// @filename: logger.svelte.d.ts
85
+
exportdeclarefunctionlogger(fn: () =>any): { value: number };
86
+
87
+
// @filename: index.js
88
+
// ---cut---
71
89
/// file: logger.svelte.test.js
72
90
import { flushSync } from'svelte';
73
91
import { expect, test } from'vitest';
@@ -135,6 +153,7 @@ export default defineConfig({
135
153
After that, you can create a test file in which you import the component to test, interact with it programmatically and write expectations about the results:
0 commit comments