Skip to content

Commit

Permalink
Merge pull request #12 from icd2k3/react-test-render
Browse files Browse the repository at this point in the history
Use shallow renderer from react-test-renderer
  • Loading branch information
icd2k3 authored Sep 13, 2018
2 parents 49fe22e + bef4993 commit ca95a73
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
exports[`jest-auto-snapshots > MyComponent Matches snapshot when boolean prop "booleanProp" is set to: "false" 1`] = `
<div>
jest-auto-snapshots String Fixture
<span>
jest-auto-snapshots Node Fixture
</span>
<NodeFixture />
</div>
`;

Expand All @@ -15,9 +13,7 @@ exports[`jest-auto-snapshots > MyComponent Matches snapshot when passed all prop
Hello
</span>
jest-auto-snapshots String Fixture
<span>
jest-auto-snapshots Node Fixture
</span>
<NodeFixture />
</div>
`;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,7 @@ exports[`jest-auto-snapshots > ShallowProps Matches snapshot when boolean prop "
jest-auto-snapshots String Fixture
</h1>
<div>
<span>
jest-auto-snapshots Node Fixture
</span>
<NodeFixture />
</div>
<button
onClick={[MockFunction]}
Expand All @@ -18,6 +16,7 @@ exports[`jest-auto-snapshots > ShallowProps Matches snapshot when boolean prop "
</button>
jest-auto-snapshots String Fixture
1
Symbol(jest-auto-snapshots String Fixture)
News
</div>
`;
Expand All @@ -31,9 +30,7 @@ exports[`jest-auto-snapshots > ShallowProps Matches snapshot when passed all pro
Hello!
</span>
<div>
<span>
jest-auto-snapshots Node Fixture
</span>
<NodeFixture />
</div>
<button
onClick={[MockFunction]}
Expand All @@ -43,6 +40,7 @@ exports[`jest-auto-snapshots > ShallowProps Matches snapshot when passed all pro
</button>
jest-auto-snapshots String Fixture
1
Symbol(jest-auto-snapshots String Fixture)
News
</div>
`;
Expand All @@ -53,9 +51,7 @@ exports[`jest-auto-snapshots > ShallowProps Matches snapshot when passed only re
jest-auto-snapshots String Fixture
</h1>
<div>
<span>
jest-auto-snapshots Node Fixture
</span>
<NodeFixture />
</div>
<button
onClick={[MockFunction]}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-auto-snapshots",
"version": "3.0.0",
"version": "3.0.1",
"description": "Fully automated Jest snapshot tests for React components",
"main": "./dist/index.js",
"repository": "git@github.com:icd2k3/jest-auto-snapshots.git",
Expand Down
6 changes: 4 additions & 2 deletions src/tests.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
import { createElement } from 'react';
import renderer from 'react-test-renderer';
import ShallowRenderer from 'react-test-renderer/shallow';

export const shapshotTest = (Component, props, str) => it(`Matches snapshot ${str}`, () => {
expect(renderer.create(createElement(Component, props)).toJSON()).toMatchSnapshot();
const renderer = new ShallowRenderer();
renderer.render(createElement(Component, props));
expect(renderer.getRenderOutput()).toMatchSnapshot();
});

/**
Expand Down

0 comments on commit ca95a73

Please sign in to comment.