Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
React Unit Test: Shallow Rendering with Enzyme
import React from 'react';
import expect from 'expect';
import { shallow } from 'enzyme';
export const NameComponent = ({ name }) => <span>Hello {name}!</span>;
describe('name component', () => {
it('should render the name', () => {
const wrapper = shallow(<NameComponent name="foo" />);
expect(wrapper.type()).toBe('span');
expect(wrapper.props().children).toEqual([ 'Hello ', 'foo', '!' ]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.