Skip to content
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

Memory leak when importing @testing-library/jest-dom in jest-setup file with NodeJS 20 #588

Open
VladimirChuprazov opened this issue Feb 28, 2024 · 0 comments

Comments

@VladimirChuprazov
Copy link

VladimirChuprazov commented Feb 28, 2024

  • @testing-library/jest-dom version: 6.4.2
  • node version: 20.11.1
  • jest version: 29.7.0
  • npm version: 10.2.4

What happened:

Jest fails with a memory leak error when importing @testing-library/jest-dom into jest setup file

Your test suite is leaking memory. Please ensure all references are cleaned.

Reproduction:

Here is the minimal reproduction repository

Problem description:

Jest has a --detectLeaks flag, which causes tests to fail if there is a memory leak. Importing @testing-library/jest-dom causes a memory leak in NodeJS v20. However, in NodeJS v18 the memory leak does not occur.

When commenting out require('aria-query'); var matchers = require('./matchers-5ae87d41.js'); and expect.extend(matchers.extensions); from ./node_modules/@testing-library/jest-dom/dist/index.js memory leak disappears. Both var matchers and require('aria-query') cause a memory leak.

Actually, when running npm run test -- --detectLeaks in the @testing-library/jest-dom repo all tests fail when using NodeJS v20.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant