Returns a string of the rendered text of the current render tree. This function should be looked at with skepticism if being used to test what the actual HTML output of the component will be. If that is what you would like to test, use enzyme's render
function instead.
Note: can only be called on a wrapper of a single node.
String
: The resulting string
const wrapper = mount(<div><b>important</b></div>); expect(wrapper.text()).to.equal('important');
function Foo() { return <div>This is</div>; } const wrapper = mount(<div><Foo /> <b>really</b> important</div>); expect(wrapper.text()).to.equal('This is really important');
© 2015 Airbnb, Inc.
Licensed under the MIT License.
https://airbnb.io/enzyme/docs/api/ReactWrapper/text.html