Testing React Components

As our applications grow more complex and we continue to add new features, we need to verify that our new implementations haven’t introduced bugs to our existing functionalities. Automated testing provides a living documentation of expected behaviors and allows us to develop with more confidence, knowing that any problems will be immediately apparent.

In this chapter, we will introduce Jest (React’s preferred testing framework) and TestUtils, a set of methods that makes it easy to test React components in any common JavaScript testing framework.


Jest is React’s recommended testing framework. It is based ...

Get Pro React now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.