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

Slow jest test (memory leak?) #18926

Closed
1 of 4 tasks
vespertilian opened this issue Aug 31, 2023 · 2 comments
Closed
1 of 4 tasks

Slow jest test (memory leak?) #18926

vespertilian opened this issue Aug 31, 2023 · 2 comments

Comments

@vespertilian
Copy link

Current Behavior

Similar to this issue which is closed, memory seems to be leaking when using Jest to test our app.

#13983

I have a sample NX app and a sample Angular CLI app, based on the samples in that issue

https://github.com/vespertilian/nx-jest-test-app
https://github.com/vespertilian/jest-preset-angular-mem-usage

It's a real issue on some of our older computers, taking upwards of 30 minutes to try to run some very (at this stage) simple specs.

I appreciate @Coly010 in issue 13983 you mention that this is a jest-preset-angular issue. However, NX pushes you into using Jest for testing Angular, I was looking at switching back to Karma, which I prefer in some ways, but NX seem to have deprecated that. While it seems I could manually configure it, this creates a lot of work for the team moving forward as the generators will not generate karma config for new apps or libs.

If NX is positioned to be an alternative to Angular CLI, I feel the test defaults it chooses should not come out of the box with memory leaks.

It takes a while to notice the memory leak as NX does such a good job of not re-running specs, as our project is also new it takes a few months before you start noticing this.

I will open an issue on jest-preset-angular, maybe you can help me push the issue forward there.

Maybe you can re-instate Karma as a first class NX citizen? That would also solve my issue

Thanks for all your work on NX it's generally really great!

image

Expected Behavior

Tests should not leak memory and complete in a reasonable time-frame.

GitHub Repo

https://github.com/vespertilian/nx-jest-test-app

Steps to Reproduce

  1. Run npm install
  2. Run npm run test

Nx Report

Node   : 18.17.1
   OS     : win32-x64
   npm    : 9.6.7

   nx                 : 16.7.4
   @nx/js             : 16.7.4
   @nx/jest           : 16.7.4
   @nx/linter         : 16.7.4
   @nx/workspace      : 16.7.4
   @nx/angular        : 16.7.4
   @nx/cypress        : 16.7.4
   @nx/devkit         : 16.7.4
   @nx/eslint-plugin  : 16.7.4
   @nrwl/tao          : 16.7.4
   @nx/webpack        : 16.7.4
   typescript         : 5.1.6

Failure Logs

No response

Package Manager Version

No response

Operating System

  • macOS
  • Linux
  • Windows
  • Other (Please specify)

Additional Information

No response

@Coly010
Copy link
Contributor

Coly010 commented Aug 31, 2023

Hi @vespertilian

I do understand that it's frustrating that there is a memory leak here, but as mentioned in the previous issue it is out of our control.

We will not be re-instating Karma. You can create a local Nx Plugin with a generator that will set this up for your projects which should reduce the work involved.

Also, Angular themselves will be moving away from Karma in the near future, preferring both Jest and Web Test Runner.

We've got improvements to our Jest solution in the pipeline and should be worked on in the coming months. We're also evaluating if we want to add support for Web Test Runner.

As this is correctly raised as an issue on jest-preset-angular, I'm going to close this issue.

@Coly010 Coly010 closed this as completed Aug 31, 2023
@github-actions
Copy link

github-actions bot commented Oct 1, 2023

This issue has been closed for more than 30 days. If this issue is still occuring, please open a new issue with more recent context.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 1, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants