Valerie Kraucunas
Software Engineer, MassRoots
Started by Airbnb engineer Leland Richardson, since open sourced
Enzyme is a JavaScript Testing utility for React.
Making it easier to
React components
Benefits of using Enzyme
Makes asking questions about the rendered component easy and intuitive by providing a fluent interface.
Getting Started
npm i --save-dev enzyme
npm i --save-dev react-addons-test-utils
npm i --save-dev react-domnpm i --save-dev chai-enzyme
npm i --save-dev jasmine-enzyme
npm i --save-dev jest-enzyme
npm i --save-dev should-enzymeOptional Assertion Libraries
*
Render All the Things!
Shallow
Render
Mount
Example of basic test
import React from 'react';
import { shallow } from 'enzyme';
import ToDoList from '../components/ToDoList';
describe('<ToDoList />', () => {
it('renders the entire list of items', () => {
const items = [mockItem(), mockItem() /*, ... */];
const wrapper = shallow(<ToDoList items={items} />);
expect(wrapper.find(ToDoList)).to.have.length(items.length);
});
});Valerie Kraucunas
valeriekraucunas@gmail.com
vkraucunas