Skip to content

Commit 53c4939

Browse files
authored
add imports to user-event intro documentation (#1256)
1 parent 1c4636a commit 53c4939

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

docs/user-event/intro.mdx

+10-2
Original file line numberDiff line numberDiff line change
@@ -59,28 +59,36 @@ itself - e.g. in a `before`/`after` hook - for reasons described in
5959
["Avoid Nesting When You're Testing"](https://kentcdodds.com/blog/avoid-nesting-when-youre-testing).
6060

6161
```js
62+
import userEvent from '@testing-library/user-event'
63+
6264
// inlining
6365
test('trigger some awesome feature when clicking the button', async () => {
6466
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
6569
render(<MyComponent />)
6670

67-
await user.click(screen.getByRole('button', {name: /click me!/i}))
71+
await user.click(screen.getByRole('button', { name: /click me!/i }))
6872

6973
// ...assertions...
7074
})
7175
```
7276

7377
```js
78+
import userEvent from '@testing-library/user-event'
79+
7480
// setup function
7581
function setup(jsx) {
7682
return {
7783
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
7886
...render(jsx),
7987
}
8088
}
8189

8290
test('render with a setup function', async () => {
83-
const {user} = setup(<MyComponent />)
91+
const { user } = setup(<MyComponent />)
8492
// ...
8593
})
8694
```

0 commit comments

Comments
 (0)