Jest-preset-angular: Performance Improvements (similiar ng-bullet)

Created on 21 Aug 2020  路  7Comments  路  Source: thymikee/jest-preset-angular

Performance Improvements (similiar ng-bullet)

Feature Request

A large Unit Test (23 Tests) is running for ~10minutes.
There is a library (ng-bullet), which avoids recompiling everything
used to configure the TestBed for every test in a suite, thus increasing the overall test execution time alot (~30 seconds).
https://github.com/topnotch48/ng-bullet-workspace/blob/master/projects/ng-bullet/README.md

Downside on this library is, that it is no longer maintained.
Are there any plans, integrating the approach of ng-bullet
in jest in the near future and thus increasing the performance of jest?

To Reproduce

  • Writing a unit test with > 20 Tests.
  • Execute the test and measure execution time
  • Install ng-bullet
  • Execute the same test and measure execution time again
  • Compare Execution times

Expected behavior

Execution time of Jest unit tests will be similiar to execution time when using ng-bullet

Link to repl or repo (highly encouraged)

envinfo

System:
OS: Windows 10 10.0.17763
CPU: (12) x64 Intel(R) Core(TM) i7-8750H CPU @ 2.20GHz
Binaries:
Node: 10.15.0 - C:\Program Files\nodejs\node.EXE
npm: 6.4.1 - C:\Program Files\nodejs\npm.CMD

Feature Request Enhancement Help Wanted

All 7 comments

definitely, I think it looks very promising.

In the root README of the linked repository the owner recommends another project, maybe we should consider both.
Referenced project.

Look at spectator, it seems to be out of the scope of the preset. Not sure how to integrate into here.

Not mantained
https://github.com/topnotch48/ng-bullet-workspace#update

@splincode
That was the whole point of this feature request. ng-bullet is not maintained, so it would be great if "jest-preset-angular" would integrate the performance boost of ng-bullet.

@r-kernberger I see.
We currently have other features in focus, but we are always open to PRs.

I think key for success of this integration is that the interface of the tests does not change (much), so that developers have a low threshold to adopt the performance boost.

E. g. this could be an integration I would love:

  import {
    async,
    ComponentFixture,
-   TestBed
  } from '@angular/core/testing';
+ import { TestBed } from 'jest-preset-angular/speedup-testbed';

  describe('suite', () => {
    let comp, userService;
    beforeEach(() => {
      TestBed.configureTestingModule({
        providers: [ WelcomeComponent, { provide: UserService, useClass: MockUserService } ]
      });
      comp = TestBed.inject(WelcomeComponent);
      userService = TestBed.inject(UserService);
    });

    it('should not have welcome message after construction', () => {
      expect(comp.welcome).toBeUndefined();
    });
  });

I gave a try with @ngneat/spectator, it is quite good in term of testing util convenience, not sure if it boosts or not.

Was this page helpful?
0 / 5 - 0 ratings