File tree 1 file changed +10
-2
lines changed
1 file changed +10
-2
lines changed Original file line number Diff line number Diff line change @@ -59,28 +59,36 @@ itself - e.g. in a `before`/`after` hook - for reasons described in
59
59
[ "Avoid Nesting When You're Testing"] ( https://kentcdodds.com/blog/avoid-nesting-when-youre-testing ) .
60
60
61
61
``` js
62
+ import userEvent from ' @testing-library/user-event'
63
+
62
64
// inlining
63
65
test (' trigger some awesome feature when clicking the button' , async () => {
64
66
const user = userEvent .setup ()
67
+ // Import `render` and `screen` from the framework library of your choice.
68
+ // See https://testing-library.com/docs/dom-testing-library/install#wrappers
65
69
render (< MyComponent / > )
66
70
67
- await user .click (screen .getByRole (' button' , {name: / click me!/ i }))
71
+ await user .click (screen .getByRole (' button' , { name: / click me!/ i }))
68
72
69
73
// ...assertions...
70
74
})
71
75
```
72
76
73
77
``` js
78
+ import userEvent from ' @testing-library/user-event'
79
+
74
80
// setup function
75
81
function setup (jsx ) {
76
82
return {
77
83
user: userEvent .setup (),
84
+ // Import `render` from the framework library of your choice.
85
+ // See https://testing-library.com/docs/dom-testing-library/install#wrappers
78
86
... render (jsx),
79
87
}
80
88
}
81
89
82
90
test (' render with a setup function' , async () => {
83
- const {user } = setup (< MyComponent / > )
91
+ const { user } = setup (< MyComponent / > )
84
92
// ...
85
93
})
86
94
```
You can’t perform that action at this time.
0 commit comments