3.0.0 • Published 6 years ago

razzle-examples-with-jest v3.0.0

Weekly downloads
6
License
MIT
Repository
-
Last release
6 years ago

Using Razzle and Jest Snapshots

How to use

Download the example or clone the whole project:

curl https://codeload.github.com/jaredpalmer/razzle/tar.gz/master | tar -xz --strip=2 razzle-master/examples/with-jest
cd with-jest

Install it and run:

yarn install
yarn test

Idea behind the example

This is an example of how to use Jest Snapshots with a Razzle project.

Snapshot tests are a very useful tool whenever you want to make sure your UI does not change unexpectedly. A typical snapshot test case for a mobile app renders a UI component, takes a screenshot, then compares it to a reference image stored alongside the test. The test will fail if the two images do not match: either the change is unexpected, or the screenshot needs to be updated to the new version of the UI component.

// src/__tests__/Home.test.js

import React from 'react';
import renderer from 'react-test-renderer';
import Home from '../Home';

it('renders Home correctly', () => {
  const tree = renderer.create(<Home />).toJSON();
  expect(tree).toMatchSnapshot();
});

When you run yarn test, a snapshot file is generated that looks like:

// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`renders Home correctly 1`] = `
<div>
  Hello World!
</div>
`;

Refer to the Jest documentation for more information.

3.0.0

6 years ago

3.0.0-alpha.2

7 years ago

3.0.0-alpha.1

7 years ago

2.4.1

7 years ago

3.0.0-alpha.0

7 years ago

2.4.0

7 years ago

2.2.0

7 years ago

2.1.1

7 years ago

2.1.0

7 years ago

2.0.4

7 years ago

2.0.3

7 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago

2.0.0-alpha.12

7 years ago

2.0.0-alpha.11

7 years ago

2.0.0-alpha.10

7 years ago

2.0.0-alpha.9

7 years ago

2.0.0-y.0

7 years ago

2.0.0-alpha.8

7 years ago

2.0.0-alpha.7

7 years ago

2.0.0-alpha.6

7 years ago

2.0.0-alpha.5

7 years ago

2.0.0-alpha.4

7 years ago

2.0.0-alpha.3

7 years ago

0.8.14

7 years ago

2.0.0-alpha.2

7 years ago

0.8.13

7 years ago

2.0.0-alpha.1

7 years ago

0.8.12

7 years ago

0.8.11

7 years ago

0.8.10

7 years ago

0.8.9

7 years ago

0.8.8

7 years ago

0.8.7

8 years ago

0.8.6

8 years ago

0.8.5

8 years ago

0.8.4

8 years ago

0.8.3

8 years ago

0.8.2

8 years ago