Skip to content

Instantly share code, notes, and snippets.

@donaldpipowitch
Created April 27, 2016 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save donaldpipowitch/341e85d336cf6b36e8e4cb3915799a8d to your computer and use it in GitHub Desktop.
Save donaldpipowitch/341e85d336cf6b36e8e4cb3915799a8d to your computer and use it in GitHub Desktop.
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