0.4.0 • Published 4 years ago

check-snapshot v0.4.0

Weekly downloads
4
License
MIT
Repository
github
Last release
4 years ago

check-snapshot Build Status Coverage Status

Simple wrapper around jest expect and react-test-renderer to eliminate snapshot testing boilerplate.

Install

yarn add -D check-snapshot

Usage

import snapshot from 'check-snapshot';
import MyComponent from '../MyComponent';

test('MyComponent', () => snapshot(<MyComponent />));

Passing options to renderer.create

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();
});
0.4.0

4 years ago

0.3.0

4 years ago

0.2.0

5 years ago

0.1.0

5 years ago

0.0.3

6 years ago

0.0.2

6 years ago

0.0.1

6 years ago