-
Notifications
You must be signed in to change notification settings - Fork 468
Closed
Description
dom-testing-libraryversion: 3.5.1reactversion: 16.4.1nodeversion: 10.4.1npm(oryarn) version: yarn 1.7.0
Relevant code or config:
Usual installation,
"testEnvironment": "node",
as jest configuration, then something like following in tests:
import { getByText } from 'dom-testing-library'
it('Suggests cities to search by', async () => {
const container = createJSDOM(...)
getByText(container, 'foobar')
})What you did:
Tried to use dom-testing-library with node environment in Jest + creating own jsdom instance in a helper and passing it to dom-testing-library.
What happened:
● Test suite failed to run
ReferenceError: window is not defined
at Object.<anonymous> (node_modules/mutationobserver-shim/dist/mutationobserver.min.js:3:1)
at Object.<anonymous> (node_modules/dom-testing-library/dist/wait-for-element.js:8:1)
at Object.<anonymous> (node_modules/dom-testing-library/dist/index.js:32:23)
Reproduction:
As above, enable node jest environment and try to use dom-testing-library with some custom container
Suggested solution:
check if shim is loaded on given container and install it only then? generally something to support no global window object in jest environment
sandeepkumaar
Metadata
Metadata
Assignees
Labels
No labels