Open GreenGremlin opened 4 years ago
Is there anything I can do to help get this merged?
I'm sure you're all pretty busy, but it would be nice to see this and https://github.com/FormidableLabs/enzyme-matchers/pull/337 merged, if possible.
Closing this PR, due to its age, but it would still be nice to have.
Age shouldn’t be a factor :-) let’s leave this open.
At some point in Enzyme v2 a change was made to
wrapper.find
to return matches for both host (aka DOM) nodes as well as custom components.Take for example this code.
The above assertion would fail because
wrapper.find('.userOne')
returns two matches,User.userOne
andspan.userOne
. This is fine, and can be worked around by qualifying the query with a tag name likespan.userOne
. The problem is that currently,toContainExactlyOneMatchingElement
prints only HTML output, and if you only see the HTML output, it seems like the assertion should not fail.This change updates the
html
function to print the full element tree usingwrapper.debug()
, ensuring it's clear why the assertion failed.I have a follow-on change to add specialized matchers that will only match against host nodes, which is why I added the
hostNodesOnly
argument to thehtml
function.