Shallow rendering with Enzyme

Enzyme is an open source JavaScript testing library that was created by Airbnb and works with almost every JavaScript library or framework. With Enzyme, you can also shallow render components to test the first level of the component, as well as render nested components, and simulate life cycles for integration tests. The Enzyme library can be installed with npm, and also needs an adapter to simulate React features. Let's get started:

  1. To install Enzyme, you need to run the following command from your Terminal, which installs Enzyme and the specific adapter for the version of React you're using:
npm install enzyme enzyme-adapter-react-16 --save-dev
  1. After installing Enzyme, you need to create a setup file that ...

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