Skip to content
A demo of how to test react components with react-testing-library (and how not to test components with enzyme)
Branch: master
Clone or download
Type Name Latest commit message Commit time
Failed to load latest commit information.
public Initial commit from Create React App Apr 6, 2019
src add link to README Apr 7, 2019
.gitignore Initial commit from Create React App Apr 6, 2019
package.json initial commit Apr 6, 2019

Testing React Components Demo

A repo that contains two components (Checklist & SelectTwo), that are written as functional and class components. The functional components as tested with react-testing-library and the class components are tested with enzyme.

This demo is used to accompany an article I wrote on the subject of testing react components with react-testing-library. I explain why react-testing-library is better than enzyme when it comes to testing react components.

Run the app

To see a live demo of the components' actual behaviour, you can run the app by using the following commands:

yarn install # install project dependencies
yarn start # start the development server at http://localhost:3000/

Screenshot of the app running locally

Run the tests

To run the tests make sure the have installed the project dependencies (see above), and then run yarn test. This will run the tests in watch mode, which watches for file changes and automatically runs tests after any file change.

You can’t perform that action at this time.