Skip to content

Jamo3939/jester

Repository files navigation

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

About

DRYs up your React + snapshot tests.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published