0

I'm writing unit tests for some React components using the handy renderIntoDocument() method, but when I look at the DOM's innerHTML, I'm getting the following:

<h3>
  <!-- react-text: 17 -->Start with <!-- /react-text -->
  <span class="theme-secondary-color"><!-- react-text: 19 -->5<!-- /react-text -->
  <!-- react-text: 20 --> Plans<!-- /react-text --></span>
</h3>

When I really would like to parse:

<h3>
  Start with <span class="theme-secondary-color">5 Plans
  </span>
</h3>

I realize that React needs the markup to do it's thing, but is there a utility to strip out the React markup in order to write tests that are easier to read?

Any help would be appreciated!

Mark Kadlec
  • 8,036
  • 17
  • 60
  • 96
  • 1
    https://facebook.github.io/react/docs/react-dom-server.html#rendertostaticmarkup – pawel Dec 14 '16 at 22:00
  • Thanks @pawel, works great! – Mark Kadlec Dec 14 '16 at 22:09
  • Possible duplicate of [Should I use ReactDOMServer.renderToString() or any other way to render a react component to a string?](https://stackoverflow.com/questions/45110293/should-i-use-reactdomserver-rendertostring-or-any-other-way-to-render-a-react) – Paul Sweatte Aug 14 '17 at 22:23

0 Answers0