I have a simple component which includes two buttons and the heading field. So far I tested button clicks but I want to test heading text field in the <h3>
tag.
My component
class Popup extends React.Component {
render() {
return (
<div className="popupOuter">
<div className="popupInner text-center">
<br/>
<h3>{this.props.config.text}</h3>
<br/>
<div>
<Button type='NoButton' value={'No'} onClick={this.props.config.back} />
<Button type = 'YesButton' value={'Yes'} onClick={this.props.config.next}/>
</div>
</div>
</div>
);
}
}
My test
test('Text test ', ()=>{
const component = shallow(
<Popup config={config}/>
);
expect(component.find('h3')).toEqual("h3");
});
My test fails with
Error: expect(received).toEqual(expected) // deep equality Expected: "h3" Received: {}
What went wrong? Explanation pls?
Thanks.