Skip to content

Latest commit

 

History

History
49 lines (36 loc) · 1.79 KB

README.md

File metadata and controls

49 lines (36 loc) · 1.79 KB

jester

CircleCI Status

Jester DRYs up your Jest + React snapshot code.

Why use jester?

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).

Packages

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 npm The basic version for creating snapshots with plain JSON
jester-react npm The React specific version for use with React Components