저는 h1과 p를 렌더링하는 React.js에 간단한 소개 구성 요소가 있습니다.ReactJS & Enzyme : 요소 내용을 문자열로 일치
전달 된 h1 & p 개의 문자열을 효소로 테스트하려고하지만이 작업을 수행 할 수 없습니다. 이 코드의 문제점은 무엇입니까?
it('description of element is okay <p>',() => {
const wrapper = shallow(<Intro title="Heading of element" description="Description of element" />);
expect(wrapper.find('p').text().to.contain("Description of element")); // This is not working!
});
나는 그것이 ... 정의되지 않은이 아니다 그럼에도 불구하고 콘솔은 다음과 같이 말한다 wrapper.find('p').text()
를 기록 콘솔 경우
expect(wrapper.find('p').text()).to.contain('Description of element')
expect
작품 :
1) (Component) Intro contains a single <p>:
TypeError: Cannot read property 'contain' of undefined
at Context.<anonymous> (test/components/alerts/alert.spec.js:19:12)