Skip to content
This repository has been archived by the owner on Aug 6, 2020. It is now read-only.

Latest commit

 

History

History
76 lines (63 loc) · 1.15 KB

debug.md

File metadata and controls

76 lines (63 loc) · 1.15 KB

.debug() => String

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.

Returns

String: The resulting string.

Examples

Say we have the following components:

class Foo extends React.Component {
  render() {
    return (
      <div className="foo">
        <span>Foo</span>
      </div>
    );
  }
}

class Bar extends React.Component {
  render() {
    return (
      <div className="bar">
        <span>Non-Foo</span>
        <Foo baz="bax" />
      </div>
    );
  }
}

In this case, running:

console.log(mount(<Bar id="2" />).debug());

Would output the following to the console:

<Bar id="2">
  <div className="bar">
    <span>
      Non-Foo
    </span>
    <Foo baz="bax">
      <div className="foo">
        <span>
          Foo
        </span>
      </div>
    </Foo>
  </div>
</Bar>

Likewise, running:

console.log(mount(<Bar id="2" />).find(Foo).debug());

Would output the following to the console:

<Foo baz="bax">
  <div className="foo">
    <span>
      Foo
    </span>
  </div>
</Foo>