Snapshot Testing (Feat. Jest)
...
"env": {
"test": {
"plugins": [
"transform-es2015-modules-commonjs"
]
}
}...
"env": {
"es6": true,
"browser": true,
"node": true,
"jest": true
}참고
Last updated
...
"env": {
"test": {
"plugins": [
"transform-es2015-modules-commonjs"
]
}
}...
"env": {
"es6": true,
"browser": true,
"node": true,
"jest": true
}Last updated
import React from 'react';
import renderer from 'react-test-renderer';
import Search from '../js/Search'; // 스냅샷을 찍을 컴퍼넌트
test('Search 컴퍼넌트가 올바르게 렌더링 되는지 확인한다.', () => {
const component = renderer.create(<Search />);
const tree = component.toJSON();
expect(tree).toMatchSnapshot();
});__tests__
__snapshots__
Search.spec.jsx.snapReceived value does not match stored snapshot 1.
- svideo
+ videoNODE_ENV=test ./node_modules/.bin/jest -u