Join egghead, unlock knowledge.

Want more egghead? It's 45% off for a limited time only!

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

Unlock All Content for 45% Off

Already subscribed? Sign In

Save 45% for a limited time.

Get access to all courses and lessons on egghead today.

Autoplay

    Test Against Different React Releases with Enzyme

    Tyler ClarkTyler Clark

    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.

    reactReact
    ^16.0.0
    jestJest
    Code

    Code

    Become a Member to view code

    You must be a 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
    Transcript

    Transcript

    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.

    Discuss

    Discuss