jeudi 17 août 2017

How to render components in fake DOM in enzym?

I have a components library and I have a Tooltip component that renders tooltip div at the very bottom of the document's body. How can I render the Tooltip component in a fake DOM and then test if the div element has appeared after I hovered Tooltip component?

So:

  1. first I have to render/mount a Tooltip component first.
  2. Simulate an event fe wrapper.find('span').simulate('mouseenter')
  3. Check if the <div> element has appeared in a right place(as last body child).

I'm stuck on point 1 and 3. How can I test it in Jest/enzyme? Should I use JSDom?

Aucun commentaire:

Enregistrer un commentaire