-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MutationObserver is not a constructor #662
Comments
Hi @FredyC, We're not responsible for polyfilling your environment. You are. If your environment doesn't support the DOM APIs we use, then you need to make it do that. Luckily, the latest versions of JSDOM does support MutationObserver. And the latest version of Jest uses the latest version of JSDOM. So update those versions and you don't need the polyfill. If you can't, then the polyfill is a good workaround. Good luck! |
I see, it sort of makes sense. I never used MutationObserver in the past and I thought it's some hot new thing 😅. Seeing it had issue in jsdom tracked since 2013 and it was released last year I can see my mistake :) I guess it all drills to CRA again which uses fossil dependencies :) So I am moving my cry next door. It was added in https://github.com/jsdom/jsdom/releases/tag/13.2.0 |
A new version of react-scripts is coming soon and it will have the latest jest/jsdom |
I added the following to the |
In case anyone is facing the same issue and other solutions did not work. run |
FYI, still need this --env=jsdom-fourteen to make waitFor working, today. |
Another confirmation, July 24th 2020 |
Yeah, I was given the impression that CRA would be updated in a matter of days after this change was made, but then something happened to delay it a lot (I think it was ESLint v7 getting released). I've been given the impression that the next version of CRA will be released in the next few days though. Hopefully that's the case and we no longer need to worry about this. |
MutationObserver is necessary for waitFor See testing-library/react-testing-library#662
Fix Jest conflict from React Scripts - Jest was manually added originally due to this [issue](testing-library/react-testing-library#662). Latest update of React Scripts has a mroe recent update of Jest and we can safely move away from manually configuring Jest on our own.
Fix Jest conflict from React Scripts - Jest was manually added originally due to this [issue](testing-library/react-testing-library#662). Latest update of React Scripts has a mroe recent update of Jest and we can safely move away from manually configuring Jest on our own.
Fix Jest conflict from React Scripts - Jest was manually added originally due to this [issue](testing-library/react-testing-library#662). Latest update of React Scripts has a mroe recent update of Jest and we can safely move away from manually configuring Jest on our own.
…ibrary API until we update CRA. See testing-library/react-testing-library#662 (comment)
Fix Jest conflict from React Scripts - Jest was manually added originally due to this [issue](testing-library/react-testing-library#662). Latest update of React Scripts has a mroe recent update of Jest and we can safely move away from manually configuring Jest on our own.
@testing-library/react
version: 10.0.4react
version: 16.12.0Relevant code or config:
What you did:
Run the test :)
What happened:
Reproduction:
https://codesandbox.io/s/practical-colden-jbnzf?file=/src/App.test.js
It actually works there, because MutationObserver is available in a browser, but apparently not in jsdom
Problem description:
It's not documented anywhere that MutationObserver would need to be polyfilled. Either way, after doing the following, problem is workaround-ed :)
Suggested solution:
I think polyfill should be part of the library to remove the hassle of users doing that.
The text was updated successfully, but these errors were encountered: