Skip to content

Commit

Permalink
Change the way we test snapshots
Browse files Browse the repository at this point in the history
This is something that is not working after the upgrade to
`react-scripts`, and also has the benefit of generating more correct and
less brittle snapshots.

The other option is adding [a proper serializer][1] like
[enzyme-to-json][2], but this option also makes things easier to
understand without adding another dependency.

[1]: jestjs/jest#7802
[2]: https://github.com/adriantoine/enzyme-to-json
  • Loading branch information
Cainã Costa committed Jun 24, 2019
1 parent e059f72 commit 78fd4b4
Show file tree
Hide file tree
Showing 40 changed files with 727 additions and 30,197 deletions.
8 changes: 4 additions & 4 deletions src/components/Details/__tests__/DetailObject.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ describe('DetailObject test', () => {
const wrapper = shallow(<DetailObject name={name} detail={detail} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(wrapper.debug()).toMatchSnapshot();

expect(wrapper.html()).toContain('<span class="text-capitalize">[host]</span>');
expect(wrapper.html()).toContain('<span class="text-capitalize">[subset]</span>');
Expand All @@ -47,7 +47,7 @@ describe('DetailObject test', () => {
const wrapper = shallow(<DetailObject name={name} detail={detail} exclude={['port']} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(wrapper.debug()).toMatchSnapshot();

expect(wrapper.html()).toContain('<span class="text-capitalize">[host]</span>');
expect(wrapper.html()).toContain('<span class="text-capitalize">[subset]</span>');
Expand All @@ -70,7 +70,7 @@ describe('DetailObject test', () => {
const wrapper = shallow(<DetailObject name={name} detail={detail} validation={validation} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(wrapper.debug()).toMatchSnapshot();

const iconWrapper = wrapper.find(Icon);
expect(iconWrapper.prop('type')).toEqual('pf');
Expand All @@ -90,7 +90,7 @@ describe('DetailObject test', () => {
const wrapper = shallow(<DetailObject name={name} detail={detail} validation={validation} />);

expect(wrapper).toBeDefined();
expect(wrapper).toMatchSnapshot();
expect(wrapper.debug()).toMatchSnapshot();

const iconWrapper = wrapper.find(Icon);
expect(iconWrapper.length).toEqual(0);
Expand Down
Loading

0 comments on commit 78fd4b4

Please sign in to comment.