react-testing-library: does not play well with jest 27

  • @testing-library/react version:

@testing-library/jest-dom”: “5.12.0”, “@testing-library/react”: “11.2.7”,

  • Testing Framework and version:

“jest”: “27.0.1”,

  • DOM Environment:

jsdom

Relevant code or config:

please refer to this project https://github.com/TrejGun/casino

What you did:

updated jest from 26 to 27

What happened:

Tests are now failing with

    ReferenceError: clearImmediate is not defined

Reproduction:

see above

Problem description:

Tests are failing 😦

Suggested solution:

N/A

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 25
  • Comments: 15 (5 by maintainers)

Most upvoted comments

Having the same issue after upgrading to Jest@27. Is anyone working on a fix?

We’re in the process of fixing this in @testing-library/dom. This particular issue should already be fixed in the alpha but it’ll take some time to test it before we can release a new major of @testing-library/react.

🎉 This issue is fixed in version 12.0.0-alpha.2 🎉

The release is available on:

I got this error : TypeError: Cannot destructure property 'AsymmetricMatcher' of '_prettyFormat.default.plugins' as it is undefined

My packages installed :

@testing-library/react@12.0.0
@testing-library/dom@8.1.0
jest@27.0.6
ts-jest@27.0.3

We have the same issue. Trying to update a monorepo with 297 test suites to jest v27 caused a full 47 test suites to fail. A couple of issues I saw:

  • Something is wrong with promise cleanup. A test of code that relied on .finally() timed out and never finished.
  • Something is wrong with timers, both real and fake. It’s possible this is just another symptom of the promise cleanup issue.
  • Clearing a mocked Date.now (created using jest.spyOn) failed (Date.now.mockClear() threw an error that mockClear wasn’t a function).
  • New messages:ReferenceError: You are trying to access a property or method of the Jest environment after it has been torn down.. These are probably leaks I could fix if I could figure out which test was being torn down.

Jest 27 config file changes I made:

  testEnvironment: 'jsdom',
  timers: 'legacy',
  testRunner: 'jasmine2',

I got this error : TypeError: Cannot destructure property 'AsymmetricMatcher' of '_prettyFormat.default.plugins' as it is undefined

My packages installed :

@testing-library/react@12.0.0
@testing-library/dom@8.1.0
jest@27.0.6
ts-jest@27.0.3

@maximeNaulleau Can you please share which version of pretty-format you have installed? It should be 27^.