File tree 1 file changed +9
-4
lines changed
docs/svelte-testing-library
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -18,7 +18,7 @@ This basic example demonstrates how to:
18
18
- Pass props to your Svelte component using ` render `
19
19
- Query the structure of your component's DOM elements using ` screen `
20
20
- Interact with your component using [ ` @testing-library/user-event ` ] [ user-event ]
21
- - Make assertions using ` expect ` , using methods added by
21
+ - Make assertions using ` expect ` , using matchers from
22
22
[ ` @testing-library/jest-dom ` ] [ jest-dom ]
23
23
24
24
``` html title="greeter.svelte"
@@ -71,9 +71,14 @@ test('greeting appears on click', async () => {
71
71
72
72
## Events
73
73
74
- Events can be tested using spy functions, like those provided by
75
- [ ` vi.fn() ` ] [ vi-fn ] . Function props are more straightforward to use and test than
76
- events, so consider using them if they make sense for your project.
74
+ Events can be tested using spy functions.
75
+ If you're using Vitest you can use [ ` vi.fn() ` ] [ vi-fn ] to create a spy.
76
+
77
+ :::info
78
+
79
+ Consider using function props to make testing events easier.
80
+
81
+ :::
77
82
78
83
``` html title="button-with-event.svelte"
79
84
<button on:click >click me</button >
You can’t perform that action at this time.
0 commit comments