Socket
Socket
Sign inDemoInstall

enzyme-react-16-adapter-setup

Package Overview
Dependencies
121
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    enzyme-react-16-adapter-setup

Easy way to setup enzyme for React 16 in Jest.


Version published
Weekly downloads
742
increased by7.07%
Maintainers
1
Install size
3.88 kB
Created
Weekly downloads
 

Readme

Source

Enzyme React 16 adapter setup

Easy way to setup enzyme for React 16 in Jest.

Instalation

# Using yarn
yarn add --dev enzyme react-test-renderer enzyme-adapter-react-16 enzyme-react-16-adapter-setup

# Or using npm
npm install --dev enzyme react-test-renderer enzyme-adapter-react-16 enzyme-react-16-adapter-setup

Setup

The idea of this package is to make a file in order to set up enzyme.

The easyest way is to use jest's setupFiles. Make sure your package.json includes the following:

{
  // ...
  "jest": {
    // ...
    "setupFiles": [
      "raf/polyfill",
      "enzyme-react-16-adapter-setup"
    ]
  }
}

Note: The example also adds requestAnimationFrame polyfill, if you are testing with jsdom, probabably you'll need it. In order to install it just do the following:

# Using yarn
yarn add --dev raf

# Or using npm
npm install --dev raf

Create React App

If you are using Create React App, you won't be able to use jest's setupFiles. You'll need to create the file src/setupTests.js with the following content:

// src/setupTests.js
import 'raf/polyfill';
import 'enzyme-react-16-adapter-setup';

Note: You'll also have to add a requestAnimationFrame polyfill as jsdom doesn't provide one:

# Using yarn
yarn add --dev raf

# Or using npm
npm install --dev raf

Keywords

FAQs

Last updated on 12 Oct 2017

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc