How to get inner html with enzyme? (html content)

Viewed 2739

in Enzyme, How we can get the content of the element, but as html?

(.text() returns text, .html() returns outerHTML)

const wrapper = shallow(<div><b>foo</b><span>cool</span></div>);
wrapper.text() // 'foocool' , like innerText in dom
wrapper.html() // '<div><b>foo</b><span>cool</span></div>' , like outerHTML in dom
wrapper.????() // '<b>foo</b><span>cool</span>' , <--------- like innerHTML in dom

Edit:

This works but isn't there a more convenient way to get it?

wrapper.children().map(el => el.html()).join('')
1 Answers
expect(wrapper.html()).toContain('<b>foo</b><span>cool</span>')
Related