File tree Expand file tree Collapse file tree 2 files changed +18
-4
lines changed
docs/svelte-testing-library Expand file tree Collapse file tree 2 files changed +18
-4
lines changed Original file line number Diff line number Diff line change @@ -25,7 +25,7 @@ tells Svelte to apply any new changes to the DOM.
25
25
26
26
## ` render `
27
27
28
- ``` jsx
28
+ ``` js
29
29
import { render } from ' @testing-library/svelte'
30
30
31
31
const { results } = render (
@@ -41,6 +41,20 @@ These are the options you pass when instantiating your Svelte `Component`.
41
41
Please refer to the
42
42
[ Client-side component API] ( https://svelte.dev/docs#Client-side_component_API ) .
43
43
44
+ 📝 If the only option you're passing in is ` props ` , then you can just pass them
45
+ in directly.
46
+
47
+ ``` js
48
+ // With options.
49
+ const { results } = render (YourComponent, {
50
+ target: MyTarget,
51
+ props: { myProp: ' value' },
52
+ })
53
+
54
+ // Props only.
55
+ const { results } = render (YourComponent, { myProp: ' value' })
56
+ ```
57
+
44
58
### Render Options
45
59
46
60
| Option | Description | Default |
@@ -69,7 +83,7 @@ Unmounts the component from the container and destroys the container.
69
83
test. If you'd like to disable this then set ` process.env.STL_SKIP_AUTO_CLEANUP `
70
84
to true or import ` dont-clean-up-after-each ` from the library.
71
85
72
- ``` jsx
86
+ ``` js
73
87
import { render , cleanup } from ' @testing-library/svelte'
74
88
75
89
afterEach (() => {
Original file line number Diff line number Diff line change @@ -33,14 +33,14 @@ import { render, fireEvent } from '@testing-library/svelte'
33
33
import Comp from ' ../Comp'
34
34
35
35
test (' shows proper heading when rendered' , () => {
36
- const { getByText } = render (Comp, { props : { name: ' World' } })
36
+ const { getByText } = render (Comp, { name: ' World' })
37
37
38
38
expect (getByText (' Hello World!' )).toBeInTheDocument ()
39
39
})
40
40
41
41
// Note: This is as an async test as we are using `fireEvent`
42
42
test (' changes button text on click' , async () => {
43
- const { getByText } = render (Comp, { props : { name: ' World' } })
43
+ const { getByText } = render (Comp, { name: ' World' })
44
44
const button = getByText (' Button' )
45
45
46
46
// Using await when firing events is unique to the svelte testing library because
You can’t perform that action at this time.
0 commit comments