Skip to content

Conversation

LLCampos
Copy link
Contributor

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.

@netlify
Copy link

netlify bot commented May 24, 2023

Deploy Preview for testing-library ready!

Name Link
🔨 Latest commit 73675ad
🔍 Latest deploy log https://app.netlify.com/sites/testing-library/deploys/64708d397bafcf0008cb1b47
😎 Deploy Preview https://deploy-preview-1256--testing-library.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site settings.

@LLCampos LLCampos changed the title Add imports to user-event documentation Add imports to user-event intro documentation May 24, 2023
@@ -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'
Copy link
Member

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.

Copy link
Contributor Author

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 :)

Copy link
Member

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),
  }

Copy link
Contributor Author

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?

Copy link
Member

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 😁

Copy link
Member

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.

Copy link
Contributor Author

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 :)

Copy link
Member

@timdeschryver timdeschryver left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@timdeschryver timdeschryver merged commit 53c4939 into testing-library:main May 29, 2023
@timdeschryver
Copy link
Member

@all-contributors please add @LLCampos for docs

@allcontributors
Copy link
Contributor

@timdeschryver

I've put up a pull request to add @LLCampos! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants