Test Against Different React Releases with Enzyme

Tyler Clark
InstructorTyler Clark
Share this video with your friends

Social Share Links

Send Tweet
Published 6 years ago
Updated 4 years ago

Within some of React’s releases there are major breaking changes that require different setups for Enzyme. In this lesson we are going to walk through how to setup your testing environment with some of these releases.

Instructor: [00:01] Once you have Enzyme installed in your workflow, it's important to know which version of React you are using. Enzyme has some adapters that need to be installed and configured in order to work with certain React releases.

[00:14] Create React app has may currently set up with React 16. In order to use Enzyme and set up our test, I need to install a package called enzyme-adapter-react-16.

[00:28] Once uploaded, we'll see it here. We can now configure our test to use this adapter. We'll go through our app test page and import configure from Enzyme.

[00:41] Next, we'll import adapter from enzyme-adapter-react-16. We'll use this configure function, which takes an object adapter, new adapter.

[00:51] Perfect, this is all we need in order to use React 16 in our test with Enzyme. We could have also created a test set-up file and put this in there, because it only needs to be at it once. For simplicity, we will leave it in this file.

[01:06] Adapters and configurations need to be set up if you're using React 16, 15, 014 or 013. The set-up is the same for each of these versions. The only thing that needs to be changed is the adapter package that we're installing.

[01:21] If you're working within React 15.5 or higher, that will be the React 15 package. If you're working within 15.0and 15.4, that will be the 15.4. If you're working with the 014, that will be the 14 package, and if you're working with 013, that will be the adapter-react-13.

egghead
egghead
~ 30 minutes ago

Member comments are a way for members to communicate, interact, and ask questions about a lesson.

The instructor or someone from the community might respond to your question Here are a few basic guidelines to commenting on egghead.io

Be on-Topic

Comments are for discussing a lesson. If you're having a general issue with the website functionality, please contact us at support@egghead.io.

Avoid meta-discussion

  • This was great!
  • This was horrible!
  • I didn't like this because it didn't match my skill level.
  • +1 It will likely be deleted as spam.

Code Problems?

Should be accompanied by code! Codesandbox or Stackblitz provide a way to share code and discuss it in context

Details and Context

Vague question? Vague answer. Any details and context you can provide will lure more interesting answers!

Markdown supported.
Become a member to join the discussionEnroll Today