Simple wrapper around jest expect and react-test-renderer to eliminate snapshot testing boilerplate.
yarn add -D check-snapshot
import snapshot from 'check-snapshot';
import MyComponent from '../MyComponent';
test('MyComponent', () => snapshot(<MyComponent />));
If you need to mock a ref you can pass an object as second argument to snapshot function. This object will be passed to renderer.create when serializing your component.
const createNodeMock = () => ({ focus: () => null });
const options = { createNodeMock }
test('MyComponent', () => snapshot(<MyComponent />, options))
// The same as:
test('MyComponent', () => {
const tree = renderer.create(<MyComponent />, options).toJSON();
expect(tree).toMatchSnapshot();
});