CHAPTER 9

image

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

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

Get Pro React 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.