Skip to content
Discussion options

You must be logged in to vote

Hi @Dalez! Thank you for reporting this, I appreciate it. It raised a gap in our docs and example caused by my oversight: I didn't update our example to the latest Jest which changed the default testing environment from jsdom to node. @testing-library/react requires a jsdom environment because it makes use of DOM elements like document.body.

You can solve the error by changing the testing environment to jsdom by adding the following comment to any test files that use @testing-library/react

/**
 * @jest-environment jsdom
 */

You can also configure the jsdom environment globally by updating the Jest testEnvironment configuration option but it's not recommended.

I will update the example and…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@Dalez
Comment options

Answer selected by Dalez
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
bug Issue was opened via the bug report template.
2 participants
Converted from issue

This discussion was converted from issue #28331 on August 20, 2021 13:33.