Jest
과 Enzyme
을 사용하여 반응 성분에 대한 단위 테스트를 구현하기 만하면됩니다.반응의 원소 순서를 테스트하는 방법
주문을 테스트 할 방법이 있습니까? 버튼이 있고 아이콘과 텍스트를 동시에 렌더링한다고 가정 해 보겠습니다.
물론 사용자에게 정렬 옵션을 제공하는 것이 좋습니다 (아이콘 먼저 또는 어린이 우선).
Button.js는
class Button extends React.Component {
constructor() {
super();
}
render() {
let content;
const icon = (<Icon type='search' />);
if (this.props.iconAlign === 'right') {
content = (<span>{this.props.children} {icon}</span>
} else {
content = (<span>{icon} {this.props.children}</span>
}
return (
<button>{content}</button>
);
}
}
어떻게 및 효소농담으로 iconAlign
소품을 테스트?
니스 해결책! 고마워... –