Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

jest-environment-enzyme

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jest-environment-enzyme

Runtime Environment for enzyme tests in jest

  • 7.1.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

jest-environment-enzyme

npm version License

Overview

Setting up Enzyme with Jest and React is a somewhat complicated process. There are a lot of dependencies, configuring adapters, etc. This module will take lessen that setup and make it more declarative. This package will also simplify your test files by declaring React, and enzyme wrappers in the global scope. This means that all of your test files don't need to include imports for React or enzyme.

The setup can be as simple as this:

yarn add jest-environment-enzyme jest-enzyme enzyme-adapter-react-* --dev

(Where * is your app's adapter that matches your React version)

For example, if you are using react-16, it should look like:

yarn add jest-environment-enzyme jest-enzyme enzyme-adapter-react-16 --dev
// package.json
"jest": {
  "setupFilesAfterEnv": ["jest-enzyme"],
  "testEnvironment": "enzyme"
}

Additionally, you can specify which enzyme adapter you want to use through the testEnvironmentOptions.enzymeAdapter.

Valid options are:

  • react13
  • react14
  • react15
  • react15.4
  • react16 (default)
// package.json
"jest": {
  "setupFilesAfterEnv": ["jest-enzyme"],
  "testEnvironment": "enzyme",
  "testEnvironmentOptions": {
    "enzymeAdapter": "react16"
  }
}

Lastly, and most importantly, this library has a hard requirement on jest-enzyme.

Keywords

FAQs

Package last updated on 29 Oct 2019

Did you know?

Socket

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc