jest-dom
jest-dom copied to clipboard
`TypeError: element.getRootNode is not a function` when using `toBeVisible` or `toBeInTheDocument`
@testing-library/jest-domversion: any version since 5.11.10nodeversion: 16.15.0npmversion: 7.2.0aurelia-testingversion: 1.1.0
Relevant code or config:
We are using the default jest testEnvironment of node.
...
const readOnlyTitle = component.querySelector("[data-spec=rtr-read-only-title]")
expect(readOnlyTitle).toBeVisible();
What you did:
upgrading jest-dom dependency from 5.11.0 to 5.16.4
What happened:
existing passing tests broke.
Reproduction:
Problem description:
Upgrading a minor version shouldn't break existing APIs.
Suggested solution:
Make sure the implementation of toBeVisible and toBeInTheDocument work with jest-environment-node and jest-environment-jsdom not just jest-environment-jsdom.
It seems the usage of element.getRootNode in toBeVisible and toBeInTheDocument does not work when using jest-environment-node.
Is there a way to change the implementation so that it works in both environments?