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

enzyme

Package Overview
Dependencies
Maintainers
4
Versions
54
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enzyme

JavaScript Testing utilities for React

  • 3.8.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
352K
decreased by-78.82%
Maintainers
4
Weekly downloads
 
Created

What is enzyme?

Enzyme is a JavaScript testing utility for React that makes it easier to assert, manipulate, and traverse your React Components' output. It is designed to work with test runners like Jest or Mocha, and it provides a more intuitive and flexible API for interacting with React component trees.

What are enzyme's main functionalities?

Shallow Rendering

Shallow rendering is useful to constrain yourself to testing a component as a unit, and to ensure that your tests aren't indirectly asserting on behavior of child components.

import { shallow } from 'enzyme';
import MyComponent from './MyComponent';

const wrapper = shallow(<MyComponent />);
expect(wrapper.find('.my-class').length).toBe(1);

Full DOM Rendering

Full DOM rendering is ideal for use cases where you have components that may interact with DOM APIs, or may require the full lifecycle in order to fully test the component (i.e., componentDidMount etc.).

import { mount } from 'enzyme';
import MyComponent from './MyComponent';

const wrapper = mount(<MyComponent />);
expect(wrapper.find('.my-class').length).toBe(1);

Static Rendering

Static rendering is used to render the component to static HTML. It's useful for rendering components to strings, for instance, to send in emails, or for analyzing the markup structure.

import { render } from 'enzyme';
import MyComponent from './MyComponent';

const wrapper = render(<MyComponent />);
expect(wrapper.find('.my-class').length).toBe(1);

Other packages similar to enzyme

Keywords

FAQs

Package last updated on 10 Dec 2018

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