Become a member
to unlock all features

Level Up!

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


    Install Enzyme and Configure Jest


    In order to get up and going with Enzyme and Jest, some configurations are required. We will need to install some babel plugins, create a specific package json script, and depending on which version of Jest, add Jest configurations to our package.json.



    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: In this course, I will be using Create React App as my background setup. Create React App comes with a lot of built-in configurations and installed dependencies that we need to get up and running with React Jest and Enzyme.

    If you're not using Create React App, you need to install as dev dependencies, Jest, babel-jest, babel-core, babel/preset-env, and babel/preset-react. Once our package is installed, we need to create a new file for our babelrc. We'll paste in our presets-env and react so that we can use ES6 and React and setup our test.

    Next, we need to make sure we have a script for actually running our test. Again, Create React App has this for us. However, one can simply just put Jest here, and that will our test as well.

    Also, if you inaudible Create React App, the Jest doc goes the detail on how to get it configured with Webpack, including how to handle select assets, CSS modules, and working with Webpack 2.

    With Jest configured, we can install as a dev dependency enzyme. Once this finishes, we will see it added to our package JSON.