Skip to content

Commit 78fd4b4

Browse files
author
Cainã Costa
committed
Change the way we test snapshots
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
1 parent e059f72 commit 78fd4b4

File tree

40 files changed

+727
-30197
lines changed

40 files changed

+727
-30197
lines changed

src/components/Details/__tests__/DetailObject.test.tsx

+4-4
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ describe('DetailObject test', () => {
3030
const wrapper = shallow(<DetailObject name={name} detail={detail} />);
3131

3232
expect(wrapper).toBeDefined();
33-
expect(wrapper).toMatchSnapshot();
33+
expect(wrapper.debug()).toMatchSnapshot();
3434

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

4949
expect(wrapper).toBeDefined();
50-
expect(wrapper).toMatchSnapshot();
50+
expect(wrapper.debug()).toMatchSnapshot();
5151

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

7272
expect(wrapper).toBeDefined();
73-
expect(wrapper).toMatchSnapshot();
73+
expect(wrapper.debug()).toMatchSnapshot();
7474

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

9292
expect(wrapper).toBeDefined();
93-
expect(wrapper).toMatchSnapshot();
93+
expect(wrapper.debug()).toMatchSnapshot();
9494

9595
const iconWrapper = wrapper.find(Icon);
9696
expect(iconWrapper.length).toEqual(0);

0 commit comments

Comments
 (0)