Skip to content

Commit a5ae8b8

Browse files
billyvgMaxBittker
authored andcommitted
chore: use jest serializer for enzyme-to-json (#5797)
* Use jest serializer for enzyme-to-json
1 parent 543a125 commit a5ae8b8

27 files changed

+69
-94
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@
8181
"lint": "node_modules/.bin/eslint tests/js src/sentry/static/sentry/app --ext .jsx"
8282
},
8383
"jest": {
84+
"snapshotSerializers": ["enzyme-to-json/serializer"],
8485
"modulePaths": [
8586
"<rootDir>/src/sentry/static/sentry"
8687
],

tests/js/spec/components/customResolutionModal.spec.jsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import CustomResolutionModal from 'app/components/customResolutionModal';
65

@@ -15,7 +14,7 @@ describe('CustomResolutionModal', function() {
1514
onSelected={() => false}
1615
/>
1716
);
18-
expect(toJson(wrapper)).toMatchSnapshot();
17+
expect(wrapper).toMatchSnapshot();
1918
});
2019
});
2120
});

tests/js/spec/components/detailedError.spec.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import DetailedError from 'app/components/errors/detailedError';
65

@@ -10,7 +9,7 @@ describe('DetailedError', function() {
109
<DetailedError heading="Error heading" message={<div>Message</div>} />
1110
);
1211

13-
expect(toJson(wrapper)).toMatchSnapshot();
12+
expect(wrapper).toMatchSnapshot();
1413
});
1514

1615
it('renders with "Retry" button', function() {
@@ -22,7 +21,7 @@ describe('DetailedError', function() {
2221
/>
2322
);
2423

25-
expect(toJson(wrapper)).toMatchSnapshot();
24+
expect(wrapper).toMatchSnapshot();
2625
});
2726

2827
it('can hide support links', function() {
@@ -35,7 +34,7 @@ describe('DetailedError', function() {
3534
/>
3635
);
3736

38-
expect(toJson(wrapper)).toMatchSnapshot();
37+
expect(wrapper).toMatchSnapshot();
3938
});
4039

4140
it('hides footer when no "Retry" and no support links', function() {
@@ -47,6 +46,6 @@ describe('DetailedError', function() {
4746
/>
4847
);
4948

50-
expect(toJson(wrapper)).toMatchSnapshot();
49+
expect(wrapper).toMatchSnapshot();
5150
});
5251
});

tests/js/spec/components/forms/booleanField.spec.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import {BooleanField} from 'app/components/forms';
65

76
describe('BooleanField', function() {
87
describe('render()', function() {
98
it('renders without form context', function() {
109
let wrapper = shallow(<BooleanField name="fieldName" />);
11-
expect(toJson(wrapper)).toMatchSnapshot();
10+
expect(wrapper).toMatchSnapshot();
1211
});
1312

1413
it('renders with form context', function() {
@@ -22,7 +21,7 @@ describe('BooleanField', function() {
2221
}
2322
}
2423
});
25-
expect(toJson(wrapper)).toMatchSnapshot();
24+
expect(wrapper).toMatchSnapshot();
2625
});
2726
});
2827
});

tests/js/spec/components/forms/emailField.spec.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import {EmailField} from 'app/components/forms';
65

76
describe('EmailField', function() {
87
describe('render()', function() {
98
it('renders', function() {
109
let wrapper = shallow(<EmailField name="fieldName" />);
11-
expect(toJson(wrapper)).toMatchSnapshot();
10+
expect(wrapper).toMatchSnapshot();
1211
});
1312

1413
it('renders with value', function() {
1514
let wrapper = shallow(<EmailField name="fieldName" value="[email protected]" />);
16-
expect(toJson(wrapper)).toMatchSnapshot();
15+
expect(wrapper).toMatchSnapshot();
1716
});
1817

1918
it('renders with form context', function() {
@@ -27,7 +26,7 @@ describe('EmailField', function() {
2726
}
2827
}
2928
});
30-
expect(toJson(wrapper)).toMatchSnapshot();
29+
expect(wrapper).toMatchSnapshot();
3130
});
3231
});
3332
});
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import {Form} from 'app/components/forms';
65

76
describe('Form', function() {
87
describe('render()', function() {
98
it('renders with children', function() {
109
let wrapper = shallow(<Form onSubmit={() => {}}><hr /></Form>);
11-
expect(toJson(wrapper)).toMatchSnapshot();
10+
expect(wrapper).toMatchSnapshot();
1211
});
1312
});
1413
});

tests/js/spec/components/forms/multipleCheckboxField.spec.jsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import {MultipleCheckboxField} from 'app/components/forms';
65

@@ -14,7 +13,7 @@ describe('MultipleCheckboxField', function() {
1413
value={['1']}
1514
/>
1615
);
17-
expect(toJson(wrapper)).toMatchSnapshot();
16+
expect(wrapper).toMatchSnapshot();
1817
});
1918

2019
it('renders with form context', function() {
@@ -31,7 +30,7 @@ describe('MultipleCheckboxField', function() {
3130
}
3231
}
3332
);
34-
expect(toJson(wrapper)).toMatchSnapshot();
33+
expect(wrapper).toMatchSnapshot();
3534
});
3635
});
3736
});

tests/js/spec/components/forms/numberField.spec.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,23 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import {NumberField} from 'app/components/forms';
65

76
describe('NumberField', function() {
87
describe('render()', function() {
98
it('renders', function() {
109
let wrapper = shallow(<NumberField name="fieldName" />);
11-
expect(toJson(wrapper)).toMatchSnapshot();
10+
expect(wrapper).toMatchSnapshot();
1211
});
1312

1413
it('renders with optional attributes', function() {
1514
let wrapper = shallow(<NumberField name="fieldName" min={0} max={100} />);
16-
expect(toJson(wrapper)).toMatchSnapshot();
15+
expect(wrapper).toMatchSnapshot();
1716
});
1817

1918
it('renders with value', function() {
2019
let wrapper = shallow(<NumberField name="fieldName" value={5} />);
21-
expect(toJson(wrapper)).toMatchSnapshot();
20+
expect(wrapper).toMatchSnapshot();
2221
});
2322

2423
it('renders with form context', function() {
@@ -32,7 +31,7 @@ describe('NumberField', function() {
3231
}
3332
}
3433
});
35-
expect(toJson(wrapper)).toMatchSnapshot();
34+
expect(wrapper).toMatchSnapshot();
3635
});
3736
});
3837
});

tests/js/spec/components/forms/passwordField.spec.jsx

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,18 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import {PasswordField} from 'app/components/forms';
65

76
describe('PasswordField', function() {
87
describe('render()', function() {
98
it('renders', function() {
109
let wrapper = shallow(<PasswordField name="fieldName" />);
11-
expect(toJson(wrapper)).toMatchSnapshot();
10+
expect(wrapper).toMatchSnapshot();
1211
});
1312

1413
it('renders with value', function() {
1514
let wrapper = shallow(<PasswordField name="fieldName" value="foobar" />);
16-
expect(toJson(wrapper)).toMatchSnapshot();
15+
expect(wrapper).toMatchSnapshot();
1716
});
1817

1918
it('renders with form context', function() {
@@ -27,7 +26,7 @@ describe('PasswordField', function() {
2726
}
2827
}
2928
});
30-
expect(toJson(wrapper)).toMatchSnapshot();
29+
expect(wrapper).toMatchSnapshot();
3130
});
3231
});
3332
});

tests/js/spec/components/forms/rangeField.spec.jsx

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,13 @@
11
import React from 'react';
22
import {shallow} from 'enzyme';
3-
import toJson from 'enzyme-to-json';
43

54
import {RangeField} from 'app/components/forms';
65

76
describe('RangeField', function() {
87
describe('render()', function() {
98
it('renders', function() {
109
let wrapper = shallow(<RangeField name="fieldName" />);
11-
expect(toJson(wrapper)).toMatchSnapshot();
10+
expect(wrapper).toMatchSnapshot();
1211
});
1312

1413
it('renders with optional attributes', function() {
@@ -22,12 +21,12 @@ describe('RangeField', function() {
2221
allowedValues={[1, 2, 3]}
2322
/>
2423
);
25-
expect(toJson(wrapper)).toMatchSnapshot();
24+
expect(wrapper).toMatchSnapshot();
2625
});
2726

2827
it('renders with value', function() {
2928
let wrapper = shallow(<RangeField name="fieldName" value={2} />);
30-
expect(toJson(wrapper)).toMatchSnapshot();
29+
expect(wrapper).toMatchSnapshot();
3130
});
3231

3332
it('renders with form context', function() {
@@ -41,7 +40,7 @@ describe('RangeField', function() {
4140
}
4241
}
4342
});
44-
expect(toJson(wrapper)).toMatchSnapshot();
43+
expect(wrapper).toMatchSnapshot();
4544
});
4645
});
4746
});

0 commit comments

Comments
 (0)