DEV Community

Discussion on: Testing a simple React component

Collapse
 
kentcdodds profile image
Kent C. Dodds

This is great! One tip: Try to avoid data-testid and *ByTestId queries. Sometimes you can't really avoid it very well (especially for the checked-items <p> tag), but often you can: testing-library.com/docs/guide-whi...

For example, instead of getByTestId('items-list') you could do: getByRole('list') and get rid of the data-testid :)

Thanks for writing this!

Collapse
 
ryands17 profile image
Ryan Dsouza

Thank you! I shall update that in the post.