geido edited a comment on issue #16792:
URL: https://github.com/apache/superset/issues/16792#issuecomment-928009954


   ### RTL
   
   > https://kentcdodds.com/blog/avoid-nesting-when-youre-testing 
   
   +1
   
   > Our test files use the test suffix. We should migrate those that use the 
spec suffix
   
   +1
   
   #### Priorities
   I think priorities should be remarked as it is a common mistake:
   https://testing-library.com/docs/queries/about/#priority
   
   #### getByTestId
   This is not viewable by the user and should only be used when the element 
isn't accessible in any other way.
   
   #### Using `act` unnecessarily
   `render` and `fireEvent` are already wrapped in `act`, so wrapping them in 
`act` again is a common mistake. Some solutions to the warning related to `act` 
might be found here: 
https://kentcdodds.com/blog/fix-the-not-wrapped-in-act-warning
   
   #### Using `*ByRole`
   By using the `name` option we can point to the items by their accessible 
name. For example:
   
   `screen.getByRole('button', {name: /hello world/i})`
   
   #### Prefer `userEvent` over `fireEvent`
   The user-event library better represents the actual user actions.
   
   `@testing-library/user-event`
   
   #### Usage of `waitFor`
   - Do not use it for elements that can be queried with `find`
   - It should only have one assertion at a time
   - Do not perform side-effects actions inside `waitFor`. Use it only for 
assertions
   
   ####  Materials:
   https://kentcdodds.com/blog/common-mistakes-with-react-testing-library
   https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles
   
   .....to be continued
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to