jest-dom toBeVisible throws: TypeError: element.getRootNode is not a function

483 Views Asked by At

We recently updated some of our project dependencies and one of them was jest-dom, we went from v5.11.0 to v5.16.4. As of v5.11.10 they introduced a new condition to the toBeVisible method so that the element had to be in the document, as part of this check its implementation calls element.getRootNode.

Since this change, our tests which use toBeVisible now fail with the following message:

TypeError: element.getRootNode is not a function

I suspect that using node as the Jest testEnvironment is the issue and that for whatever reason the Node implementation doesn't have getRootNode and it probably should.

Is there a way round this (without changing the test environment to jsdom, since that causes loads of tests to break)?

0

There are 0 best solutions below