Skip to Main Content
React Projects
book

React Projects

by Roy Derks
December 2019
Intermediate to advanced content levelIntermediate to advanced
474 pages
10h 3m
English
Packt Publishing
Content preview from React Projects

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 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

React Projects - Second Edition

React Projects - Second Edition

Roy Derks
Test-Driven React

Test-Driven React

Trevor Burnham

Publisher Resources

ISBN: 9781789954937Supplemental Content