My React component has a suggestionRenderer
property that allows to specify how the component is rendered. For example:
<Autosuggest suggestions={getSuburbs}
suggestionRenderer={renderLocation} />
function renderLocation(suggestion, input) {
return (
<span><strong>{suggestion.slice(0, input.length)}</strong>{suggestion.slice(input.length)}</span>
);
}
Now, I'd like to write a jest test to make sure that suggestionRenderer
does its job. Inspecting myElement.getDOMNode().innerHTML
reveals:
<span data-reactid=".9.1.$suggestion0.0"><strong data-reactid=".9.1.$suggestion0.0.0">M</strong><span data-reactid=".9.1.$suggestion0.0.1">ill Park</span></span>
which is not particularly useful.
Is there a way to get a clean HTML, without React attributes?