dom-testing-library: getByText throws node.matches is not a function
I have the following test:
getByText(fixture.nativeElement, text);
I get the error:
node.matches is not a function
After debugging, I found that the problem is in the following line:
return Array.from([...baseArray, ...container.querySelectorAll(selector)])
.filter(node => !ignore || !node.matches(ignore))
.filter(node => matcher(getNodeText(node), node, text, matchNormalizer))
One of the nodes is a NodeList, and therefore we get the error.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 39 (23 by maintainers)
๐ This issue has been resolved in version 3.16.8 ๐
The release is available on:
npm package (@latest dist-tag)Your semantic-release bot ๐ฆ๐
Why donโt we just change it to:
[...baseArray, ...Array.from(container.querySelectorAll(selector))]?
Yes, itโs Angular, but itโs a standard DOM element.
Will be fixed by https://github.com/kentcdodds/dom-testing-library/pull/213
EDIT: Maybe? Waiting confirmation for that.
EDIT2: No, will not be fixed by #213. This is likely caused by #109 way further down in history where the
node.matchesline was first added