Jester DRYs up your Jest + React snapshot code.
Jester React will reduce the amount of boilerplate you write significantly.
Example without jester:
import { Header, Paragraph } from './components';
import { shallow } from 'enzyme';
import toJSON from 'enzyme-to-json';
describe('components', () => {
test('header should match snapshot', () => {
const tree = toJson(shallow(<Header />));
expect(tree).toMatchSnapshot();
});
test('paragraph should match snapshot', () => {
const tree = toJson(shallow(<Paragraph />));
expect(tree).toMatchSnapshot();
});
});
Example with jester:
import * as Components from './components';
import jester from '@scotia/jester-react';
describe('shallow', () => {
jester.runShallowSnapshotTests(Components);
});
As you can see for each component that is added the more boilerplate code jester saves you (about 4 lines per component).
This repository is a monorepo that we manage using Lerna. That means that we actually publish multiple packages to npm from the same codebase, including:
Package | Version | Description |
---|---|---|
jester |
The basic version for creating snapshots with plain JSON | |
jester-react |
The React specific version for use with React Components |