Join egghead, unlock knowledge.

Want more egghead?

This lesson is for members. Join us? Get access to all 3,000+ tutorials + a community with expert developers around the world.

Unlock This Lesson
Become a member
to unlock all features

Level Up!

Access all courses & lessons on egghead today and lock-in your price for life.


    Test Against Different React Releases with Enzyme


    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.



    Become a Member to view code

    You must be a Pro Member to view code

    Access all courses and lessons, track your progress, gain confidence and expertise.

    Become a Member
    and unlock code for this lesson
    orLog In




    Instructor: 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.

    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.

    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.

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

    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.

    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.

    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.