jaredpalmer / tsdx

Zero-config CLI for TypeScript package development
https://tsdx.io
MIT License
11.26k stars 508 forks source link

Jest: MutationObserver is not a constructor #724

Closed jantimon closed 4 years ago

jantimon commented 4 years ago

Can we please upgrade jest to fix this problem? https://github.com/testing-library/react-testing-library/issues/662

agilgur5 commented 4 years ago

As that issue says, you need to supply some polyfill or configure JSDOM. You can already do that in Jest 24. I do not know what versions of JSDOM support MutationObserver, but if you want to use JSDOM 16, you can install and configure jest-environment-jsdom-sixteen per the docs.

A breaking upgrade for Jest 25 and a few other deps is already slated for v0.14.0 and there is already a PR for it. Jest 25 uses JSDOM 15 by default however, not 16, so I do not know if that supports your use case or not. Jest 26 is still very recent and support is TBD because it also requires TS 3.8+ which breaks a number of dependencies