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

Performance regression on jest tests after upgrading to Angular 19 #1899

Open
Abreuvoir opened this issue Jan 15, 2025 · 1 comment
Open

Comments

@Abreuvoir
Copy link

Abreuvoir commented Jan 15, 2025

Describe the Bug

Since we upgraded to Angular 19, with @angular-builders/jest 19 too, we have a huge performance regression. Locally and in our CI of our project, tests went from around 2 minutes of execution time to 15 minutes.

Minimal Reproduction

Example of a test that now takes between 8-10s to execute:

import { createComponentFactory, Spectator } from '@ngneat/spectator/jest';

import { BreadcrumbItemComponent } from './breadcrumb-item.component';

describe(BreadcrumbItemComponent.name, () => {
  let spectator: Spectator<BreadcrumbItemComponent>;

  const createComponent = createComponentFactory({
    component: BreadcrumbItemComponent,
    declareComponent: false
  });

  beforeEach(() => {
    spectator = createComponent();

    spectator.detectChanges();
  });

  it('should create', () => {
    expect(spectator.component).toBeTruthy();
  });
});
import {
  ChangeDetectionStrategy,
  Component,
  ViewEncapsulation
} from '@angular/core';

@Component({
  selector: 'breadcrumb-item',
  template: `<ng-content />`,
  changeDetection: ChangeDetectionStrategy.OnPush,
  encapsulation: ViewEncapsulation.None
})
export class BreadcrumbItemComponent {}

But the issue is noticeable on a scale, however i am not sure what to give more here without having to share company code.

Expected Behavior

Same performance as before

Screenshots

image

Environment


Libs
- @angular/core version: 19.0.5
- @angular-devkit/build-angular version: 19.0.6
- @angular-builders/jest version: 19.0.0

For Tooling issues:
- Node version: 22.11.0
- Platform:  Windows, and Jenkins on Openshift
Others:
We are using @ngneat/[email protected] 
@akornet
Copy link

akornet commented Jan 31, 2025

Found a solution that restores the performance from previous versions; just add the option isolatedModules: true to the CommonJS preset in jest.config.ts (also available for ESM) - here's the minimal file (see also this chapter in jest-preset-angular docs):

import type { Config } from 'jest';
import presets from 'jest-preset-angular/presets';

export default {
  ...presets.createCjsPreset({ isolatedModules: true }),
} satisfies Config;

My source was to check and compare the Angular 19 example presets.

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

2 participants