-
Notifications
You must be signed in to change notification settings - Fork 308
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 Improvements (similiar ng-bullet) #449
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. |
Look at spectator, it seems to be out of the scope of the preset. Not sure how to integrate into here. |
@splincode |
@r-kernberger I see. 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. |
Is this idea still valid or is it irrelevant with the latest changes from Angular? |
Not quite sure still valid, I haven’t looked into what ng-bullet does. Ng-bullet is a test util library rather than a Jest transformer. It is more related to how tests in Angular are setup or tear down. |
@ahnpnl I know the If you take a closer look at what ng-bullet does... export const configureTestSuite = (configureAction?: () => void) => {
const testBedApi: any = getTestBed();
const originReset = TestBed.resetTestingModule; // it backups the original resetTestingModule method that cleans up the TestBed
beforeAll(() => {
TestBed.resetTestingModule();
TestBed.resetTestingModule = () => TestBed; // then in the beforeAll hook it overrides the original method by just returning the dirty TestBed
});
if (configureAction) {
beforeAll((done: DoneFn) => (async () => {
configureAction();
await TestBed.compileComponents();
})().then(done).catch(done.fail));
}
// in the afterEach hook the TestBed is cleaned up, kind of but not really
// it just destroys fixtures, sets a flag, resets the test module ref, but everything else remains dirty
afterEach(() => {
testBedApi._activeFixtures.forEach((fixture: ComponentFixture<any>) => fixture.destroy());
// reset ViewEngine TestBed
testBedApi._instantiated = false;
// reset Ivy TestBed
testBedApi._testModuleRef = null;
});
// then in the afterEach hook it restores the original resetTestingModule method, and actually resets the TestBed
afterAll(() => {
TestBed.resetTestingModule = originReset;
TestBed.resetTestingModule();
});
}; If you asked me, I would not recommend using this approach. And yes, you're right. It has nothing to do with Jest transformers. |
Hi folks I have such result: |
Swc doesn’t support AST transformers which Angular needs |
@ahnpnl Isn't swc's plugin system kind of an AST transformer interface? |
Angular transformers require the context of |
@alan-agius4 maybe angular team can help with current discussion? |
We highly depend on this angular/angular#43165 If that is implemented which the |
The program is needed because in TypeScript you cannot get the typechecker otherwise. This is related to this topic angular/angular#43131 |
@ahnpnl |
The typechecker in the mentioned case is required to get certain information of symbols (which is not possible without it), this information is needed to perform the constructor transformations. |
@ahnpnl @alan-agius4
|
Thanks for the information. If The plan for Angular in the future would be still angular/angular#43131 which changes in the Angular internal architecture, which would simplify a lot efforts for 3rd party tools. |
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
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
The text was updated successfully, but these errors were encountered: