(Jest, Enzyme) 컴포넌트 단위, 통합 테스트 - connect-foundation/2019-12 GitHub Wiki
State => 단위 테스트 with Jest
import{doIncrement,doDecrement}from'./App';describe('Local State',()=>{it('should increment the counter in state',()=>{conststate={counter: 0};constnewState=doIncrement(state);expect(newState.counter).to.equal(1);});it('should decrement the counter in state',()=>{conststate={counter: 0};constnewState=doDecrement(state);expect(newState.counter).to.equal(-1);});});
Component => 단위 / 통합 테스트 with Enzyme
describe('App Component',()=>{it('Counter 래퍼를 그려낸다',()=>{constwrapper=shallow(<App/>);expect(wrapper.find(Counter)).to.have.length(1);});it('Counter 래퍼에 모든 Prop이 전달되었다',()=>{constwrapper=shallow(<App/>);letcounterWrapper=wrapper.find(Counter);expect(counterWrapper.props().counter).to.equal(0);wrapper.setState({counter: -1});counterWrapper=wrapper.find(Counter);expect(counterWrapper.props().counter).to.equal(-1);});});