geido commented 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 #### Using `act` unnecessarily > render and fireEvent are already wrapped in act 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. `screen.getByRole('button', {name: /hello world/i})` Roles reference: https://developer.mozilla.org/en-US/docs/Web/Accessibility/ARIA/Roles #### 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 .....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]
