10 Unit-testing React

This chapter covers

  • Using common testing terminology
  • Testing React components correctly
  • Adding tests for custom hooks

How do we know that our React applications work as intended? Well, we can click around and see whether everything works the way we want it to work, right? We might forget to click some button or straight up forget some unlikely but possible combination of events. Also, if we’re testing our application manually, we have to remember to do all the tests every time we change something to make sure that we didn’t break something else.

That approach, of course, is a terrible way to ensure persistent quality in your application. Instead, quality assurance is a prime candidate for automation. With automated ...

Get React in Depth now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.