Adding Enzyme Tests to your React project

Projected Time

About 2 hours

Prerequisites

Here are links to lessons that should be completed before this lesson:

Motivation

Objectives

Participants will be able to:

Specific Things to Learn

Materials

Lesson

Supplemental Resource

Common Mistakes / Misconceptions

Challenge

Read Jest’s tutorial on Snapshot Testing and try to implement the test on the code created in the lesson done above.

Check for Understanding

Find a partner, then go to the test file of Airbnb’s Rheostat’s project. Pick an it() test statement that contains either shallow or mount, then try to guess what it does and explain it to your partner. Look up Enzyme doc for unfamiliar methods. Note that the test file also uses Sinon and chai. In those cases, the methods may be found in the documentation for Sinon or chai instead.