You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
received value must be an HTMLElement or an SVGElement.
Problem description:
Several Testing Libraries are having their TypeScript types updated to take Element rather than HTMLElement as arguments so other element types like SVGElement are allowed. However, Jest DOM performs runtime checks against HTMLElement and SVGElement, so that any other element type would fail.
Any ideas on a workaround for this currently? We have some HTMLSpanElements that appear to fail a .toBeInTheDocument check as a result
This one is kind of interesting because our code isn't actually using typescript, I suspect this is coming from an underlying library we are making use of.
EDIT: We ended up just using toBeTruthy() and leaving a comment with a link to this issue
Hm, actually it's possible that my issue is something else entirely. My objects seem to be instances of HTMLElement but not instances of ownerDocument.defaultView.HTMLElement, which is what the helper is actually checking. This code involves some multi-document stuff, my issue is possibly not this issue, so I'll have to keep looking 👀 Sorry for the noise!
Relevant code or config:
What happened:
received value must be an HTMLElement or an SVGElement.
Problem description:
Several Testing Libraries are having their TypeScript types updated to take
Element
rather thanHTMLElement
as arguments so other element types likeSVGElement
are allowed. However, Jest DOM performs runtime checks againstHTMLElement
andSVGElement
, so that any other element type would fail.Suggested solution:
We should update our typechecking to check
instanceof Element
for consistency with #306 and testing-library/react-testing-library#833.The text was updated successfully, but these errors were encountered: