Skip to content
This repository has been archived by the owner on Jun 17, 2024. It is now read-only.

Testing visuals with React Testing Library #840

Closed
pcattori opened this issue Sep 22, 2020 · 2 comments
Closed

Testing visuals with React Testing Library #840

pcattori opened this issue Sep 22, 2020 · 2 comments

Comments

@pcattori
Copy link

pcattori commented Sep 22, 2020

I'm sold on using RTL for testing functional parts of my React app (e.g. if I click this button, make sure my list of books is updated to include another book).

How would you suggest to test the visuals? E.g. is the button visible?

Complexity that I see:

  • display: none
  • visibility: hidden
  • 0 area (width: 0 and height: 0)
  • overflow: hidden and this is positioned absolutely outside of the parent
  • another component is covering/overlapping it
  • text on the button is now the same color as the background, making it less usable to the user
  • ...

I could use expect(...).toHaveStyle(...) from RTL.

I'm not convinced that such writing such visual tests is worth it or that I would know what specific styles to test for.

Curious if you have advice on how to test or if its not worth testing such things.

@pcattori
Copy link
Author

From your livestream about Epic React: sounds like you are a proponent of visual regression testing for this sort of thing. I believe you mentioned Applitools specifically

@kentcdodds
Copy link
Owner

Yup! That's right :)

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

No branches or pull requests

2 participants