Writing a Component Test with React Testing Library

Learn how to refactor the component test that was implemented in the last lesson to produce robust tests using React Testing Library.

Refactoring the component test

The starter project for this lesson is the project we finished in the last lesson. It contains a test on an ErrorMessage component that verifies that the value of the message prop is rendered correctly.

The starter project was created by Create React App. So, along with Jest, React Testing Library is already installed and configured.

The starter code is available in the code widget below:

Get hands-on with 1400+ tech skills courses.