-
Notifications
You must be signed in to change notification settings - Fork 726
Add imports to user-event
intro documentation
#1256
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for testing-library ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
user-event
documentationuser-event
intro documentation
@@ -59,6 +59,8 @@ itself - e.g. in a `before`/`after` hook - for reasons described in | |||
["Avoid Nesting When You're Testing"](https://kentcdodds.com/blog/avoid-nesting-when-youre-testing). | |||
|
|||
```js | |||
import userEvent from '@testing-library/user-event' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with the comments.
On a similar note, I think adding imports to screen
and MyComponent
can also be included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added imports to render and screen, but unsure what to do about MyComponent - I'm not a React person :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure we should include the render
import here, as it (re)introduces references to specific framework libraries.
A code comment might be better:
return {
user: userEvent.setup(),
// Import `render` from the framework library of your choice.
// See https://testing-library.com/docs/dom-testing-library/install#wrappers
...render(jsx),
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we do that for both screen
and render
we then end up with almost more comments than code? :)
Should we just have the import for userEvent
since it is what this page is about?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then end up with almost more comments than code? :)
Not necessarily a bad thing – especially in docs 😁
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course I did not think about that 😅
Adding a comment sounds good to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just added the suggested comments :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
@all-contributors please add @LLCampos for docs |
I've put up a pull request to add @LLCampos! 🎉 |
It took me a while to understand how to import
userEvent
and even to understand that it was a separate library. 😶🌫️I think adding these imports would make it clearer for users that get into the page and quickly scroll for the code examples.