DEV Community

loading...

Discussion on: Don't use getByTestId 🐙

Collapse
jacques_blom profile image
Jacques Blom Author

Thanks, Jack! 🙌

Definitely agree with that. The approach I've taken with my tests is to mostly write integration tests for my UIs. I like that you're testing the way the user experiences the app. If a test that tests a user's experience breaks (if it's not a false positive), you know a real user is likely going to experience that issue.

I definitely see the value in unit tests, though. I write a bunch of tests for individual functions and hooks in my code that are important to the app functioning, and where that function's behavior isn't easy to test with an integration test. Of course, the downside here is that you're testing implementation details and your code changing will break your tests - but that's kind of the point like you said. 😊