how to use wrapper.find to find the text of div’ div element

  enzyme, javascript, jestjs, react-hooks, reactjs

I am trying to write enzyme test and would like to access the text of the following div.

<div className="toolbar__contentInformation">
   <div className="text smallfont ellipsis">Alex</div>
   <div className="text smallfont ellipsis">12</div>
</div>

test.js

  let component = React.createElement(App});
  let wrapper = enzyme.enzyme.mount(component);
  let val = wrapper.find('div.toolbar__contentInformation') //how to access text = Alex ???

Source: Ask Javascript Questions

LEAVE A COMMENT