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

enzyme-to-json

Package Overview
Dependencies
Maintainers
2
Versions
55
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

enzyme-to-json

convert enzyme wrapper to a format compatible with Jest snapshot

  • 3.6.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created

What is enzyme-to-json?

The enzyme-to-json package is a utility that converts Enzyme wrappers to a format compatible with Jest snapshot testing. It helps in serializing Enzyme wrappers so that they can be easily compared in Jest snapshot tests.

What are enzyme-to-json's main functionalities?

Convert Enzyme wrapper to JSON

This feature allows you to convert an Enzyme wrapper into a JSON object. This is particularly useful for snapshot testing with Jest, as it allows you to serialize the component's output and compare it to a saved snapshot.

const enzymeToJson = require('enzyme-to-json');
const { shallow } = require('enzyme');
const React = require('react');
const MyComponent = () => <div>Hello World</div>;
const wrapper = shallow(<MyComponent />);
const json = enzymeToJson(wrapper);
console.log(json);

Snapshot testing with Jest

This feature demonstrates how to use enzyme-to-json in conjunction with Jest for snapshot testing. By converting the Enzyme wrapper to JSON, you can easily create and compare snapshots to ensure your component's output remains consistent over time.

const enzymeToJson = require('enzyme-to-json');
const { shallow } = require('enzyme');
const React = require('react');
const MyComponent = () => <div>Hello World</div>;
test('MyComponent matches snapshot', () => {
  const wrapper = shallow(<MyComponent />);
  expect(enzymeToJson(wrapper)).toMatchSnapshot();
});

Other packages similar to enzyme-to-json

Keywords

FAQs

Package last updated on 08 Apr 2021

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