question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Not compatible with jest 27

See original GitHub issue
  • @testing-library/dom version: 7.31.0
  • Testing Framework and version: Jest 27.0.1
  • DOM Environment: jsdom: 16.6

What you did:

After upgrading to jest v27 I get an error:

  ● Test suite failed to run

    TypeError: Cannot destructure property 'DOMElement' of '_prettyFormat.default.plugins' as it is undefined.

      at Object.<anonymous> (node_modules/@testing-library/dom/dist/pretty-dom.js:33:3)
      at Object.<anonymous> (node_modules/@testing-library/dom/dist/config.js:11:18)

Problem description:

I believe jest’s pretty-format package changed from exporting on “default” to exporting directly. Even though dom testing library requires a older version, jest requires the newer version, so when dom testing library requires it, it gets the newer version…

Suggested solution:

I can only think to publish a new major version which will not be compatible with jest 26 but will work with jest 27. I believe you just need to remove .default.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:24
  • Comments:9 (2 by maintainers)

github_iconTop GitHub Comments

21reactions
andrevenanciocommented, Jul 9, 2021

It doesn’t work for me. I’m running @testing-library/dom 8.1.0 and jest27.0.6`.

See multiple TypeError: Cannot destructure property 'AsymmetricMatcher' of '_prettyFormat.default.plugins' as it is undefined. warnings on my tests.

8reactions
signal-intrusioncommented, Aug 3, 2021

I found a workaround: uninstall @types/jest, delete your package-lock.json, re-install.

The problem is that jest-diff@26.x uses an incompatible version of pretty-format. For some reason, @types/jest depends on jest-diff@26.x (https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/jest/package.json#L4-L5). And for another reason, when you run jest with an npm script, jest uses jest-diff@26 from @types/jest which uses the old, incompatible pretty-format, even if you’ve installed pretty-format and jest-diff@27 as top level dependencies!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Jest 27: New Defaults for Jest, 2021 edition
It has amassed well above a hundred comments, not even taking into ... we are now confident that jest-circus is highly compatible with ......
Read more >
ts-jest - npm
ts-jest. A Jest transformer with source map support that lets you use Jest to test projects written in TypeScript. NPM version NPM downloads ......
Read more >
Stencil: Jest 27 Upgrade Instructions - Ionic Blog
Stencil v2.13.0 includes support for Jest v27, but does not require any project to ... backwards compatibility between older versions of Jest and...
Read more >
does not export a "getVmContext" method, which is mandatory ...
does not export a "getVmContext" method, which is mandatory from Jest 27. This method is a replacement for "runScript" · node.js · unit-testing ......
Read more >
Jest 27.x: Wrong results with jest test.each : WEB-54816
WEB-51316 Jest 27, each() tests with variable interpolation: tests not represented in UI when running individual tests.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found