You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
Running tests that use asynchronous functions (e.g. await screen.findByText(/dialog/i)) from React Testing Library (RTL) produce failing tests with the following error message:
Several of these solutions hinge on the existence of react-scripts as part of a Create React App project. Synectic is not a CRA app and therefore cannot upgrade react-scripts in order to obtain a dependency that uses the jest-environment-jsdom-sixteen package. Further, we use enzyme and jest-enzyme packages, in similar fashion to testing-library/dom-testing-library#477 (comment):
Maybe it would be helpful for someone...
In my case even updating to the latest jest 26.x didn't solve the problem. That was because we used to use enzyme with jest-enzyme package (we have not migrated all spec to testing-lib yet).
The problem is that the latest jest-enzyme package has dependency on jest-environement-jsdom in old version 24.9.0 🤦
Versions (please complete the following information):
Describe the bug
Running tests that use asynchronous functions (e.g.
await screen.findByText(/dialog/i)
) from React Testing Library (RTL) produce failing tests with the following error message:TypeError: MutationObserver is not a constructor
Several related issues (react-testing-library#731, dom-testing-library#477 (comment), and dom-testing-library@7.0.0) provide resolution suggestions that include:
react-scripts
updates to the latest version of Jest.jest-environment-jsdom-sixteen
and then update yourtest
script:MutationObserver
constructor towindow
via@sheerun/mutationobserver-shim
:npm install --save-dev @sheerun/mutationobserver-shim # yarn add --dev @sheerun/mutationobserver-shim
MutationObserver
through a globally-scoped override import, per TypeError: MutationObserver is not a constructor testing-library/react-testing-library#731 (comment):jest-environment-jsdom
:Add to
package.json
:Several of these solutions hinge on the existence of
react-scripts
as part of a Create React App project. Synectic is not a CRA app and therefore cannot upgradereact-scripts
in order to obtain a dependency that uses thejest-environment-jsdom-sixteen
package. Further, we useenzyme
andjest-enzyme
packages, in similar fashion to testing-library/dom-testing-library#477 (comment):Versions (please complete the following information):
development
)Additional context
N/A
The text was updated successfully, but these errors were encountered: