const wrapper = mount(
<Header title="Title" description="Description" />,
);
wrapper.debug()
Returns an HTML-like string of the wrapper for debugging purposes. Useful to print out to the console when tests are not passing when you expect them to.
<Header>
<div className="body">
<h3 className="title">Title</h3>
<p className="description">Description</p>
</div>
</Header>
const wrapper = mount(
<Header title="Title" description="Description" />,
);
wrapper.find()
// compound selector
expect(wrapper.find('div.some-class')).to.have.lengthOf(3);
// CSS id selector
expect(wrapper.find('#foo')).to.have.lengthOf(1);
// property selector
expect(wrapper.find('[htmlFor="checkbox"]')).to.have.lengthOf(1);
Finds every node in the render tree of the current wrapper that matches the provided selector.
const wrapper = mount(
<Header title="Title" description="Description" />,
);
wrapper.props()
expect(wrapper.props().title).to.equal('Title');
Returns the props object for the root node of the wrapper. It must be a single-node wrapper.
The wrapper.props() method is especially useful when validating prop values for rendered component's children.
const wrapper = mount(
<Header title="Title" description="Description" />,
);
wrapper.text()
Returns a string of the rendered text of the current render tree.