jest-serializer-enzyme

1.0.0 • Public • Published

jest-serializer-enzyme

This is a serializer for Enzyme backed by enzyme-to-json, I suggest looking at enzyme-to-json for the implementation details

Install it

npm install --save-dev jest-serializer-enzyme

Add it to your jest config

"jest"{
  "snapshotSerializers": ["<rootDir>/node_modules/jest-serializer-enzyme"]
}

More about Jest's snapshotSerializer config here.

Enjoy

import React from 'react';
import { shallow } from 'enzyme';
 
const Bar = ({ text }) => <p>{text}</p>
 
const Foo = () => (
  <div>
    <Bar text="The text" />
  </div>
);
 
it('Renders', () => {
  const wrapper = shallow(<Foo />);
  expect(wrapper).toMatchSnapshot();
});

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.0
    2,789
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.0
    2,789
  • 0.2.0
    0
  • 0.1.3
    35
  • 0.1.2
    0
  • 0.1.1
    0

Package Sidebar

Install

npm i jest-serializer-enzyme

Weekly Downloads

2,382

Version

1.0.0

License

ISC

Last publish

Collaborators

  • rogeliog