Skip to content

Commit d274860

Browse files
amyleesalesforcealexiscordova
authored andcommitted
fix(vrt): switch to Jest DOM-only testing (#3410)
1 parent 90e9d5c commit d274860

File tree

35 files changed

+3806
-1062
lines changed

35 files changed

+3806
-1062
lines changed

jest.helpers.js

+6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import { assertMatchesDOM } from '@salesforce-ux/instant-vrt/matcher';
88
import fetch from 'isomorphic-fetch';
99
import ReactDOM from 'react-dom/server';
10+
import renderer from 'react-test-renderer';
1011

1112
import { beautify } from './shared/utils/beautify';
1213
import { renderWithBetterError } from './shared/utils/react';
@@ -21,6 +22,11 @@ export default (directory, port) => {
2122
});
2223

2324
return {
25+
matchesMarkup: reactElement => {
26+
// https://jestjs.io/docs/en/snapshot-testing#snapshot-testing-with-jest
27+
const dom = renderer.create(reactElement).toJSON();
28+
expect(dom).toMatchSnapshot();
29+
},
2430
matchesMarkupAndStyle: async element => {
2531
const renderedMarkup =
2632
typeof element === 'string'

package.json

+1
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@
131131
"raw-loader": "0.5.1",
132132
"react": "16.2.0",
133133
"react-dom": "16.2.0",
134+
"react-test-renderer": "16.4.1",
134135
"rimraf": "2.6.1",
135136
"sass-loader": "6.0.6",
136137
"strip-indent": "2.0.0",

0 commit comments

Comments
 (0)