Skip to content

Instantly share code, notes, and snippets.

@hdsenevi
Last active December 11, 2018 09:00
Show Gist options
  • Save hdsenevi/2c078c75eb397197ab84d58865bd00bc to your computer and use it in GitHub Desktop.
Save hdsenevi/2c078c75eb397197ab84d58865bd00bc 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';
jest.mock('Platform', () => {
const Platform = require.requireActual('Platform');
Platform.OS = 'ios';
return Platform;
})
describe('Button', () => {
describe('Rendering', () => {
it('should match to snapshot', () => {
const component = shallow(<Button label="test label"/>)
expect(component).toMatchSnapshot()
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment