Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 786 Bytes

html.md

File metadata and controls

46 lines (31 loc) · 786 Bytes

.html() => String

Returns a string of the rendered HTML markup of the current render tree.

Note: can only be called on a wrapper of a single node.

Returns

String: The resulting HTML string

Examples

function Foo() {
  return (<div className="in-foo" />);
}
function Bar() {
  return (
    <div className="in-bar">
      <Foo />
    </div>
  );
}
const wrapper = shallow(<Bar />);
expect(wrapper.html()).to.equal('<div class="in-bar"><div class="in-foo"></div></div>');
expect(wrapper.find(Foo).html()).to.equal('<div class="in-foo"></div>');
const wrapper = shallow(<div><b>important</b></div>);
expect(wrapper.html()).to.equal('<div><b>important</b></div>');

Related Methods

.text() => String