Skip to content

Instantly share code, notes, and snippets.

@hdsenevi
Created December 11, 2018 11:29
Show Gist options
  • Save hdsenevi/7fef177471f88b4244d0c9f44920f050 to your computer and use it in GitHub Desktop.
Save hdsenevi/7fef177471f88b4244d0c9f44920f050 to your computer and use it in GitHub Desktop.
Article helper gist for "Unit testing in React Native with Jest and Enzyme" (https://github.com/hdsenevi/react-native-unit-testing-recipes)
import React from 'react';
import {shallow} from 'enzyme';
import Button from './Button';
describe('Button', () => {
describe('Rendering', () => {
it('should match to snapshot - Primary', () => {
const component = shallow(<Button label="test label" primary />)
expect(component).toMatchSnapshot("Primary button snapshot")
});
it('should match to snapshot - Secondary', () => {
const component = shallow(<Button label="test label" primary={false} />)
expect(component).toMatchSnapshot("Secondary button snapshot")
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment