Menu

Faster Angular tests with setupTestBed – selleo – Medium

November 11th, 2017

  • Faster Angular tests with setupTestBedMichal Pierzchala’s jest-preset-angular makes Angular tests faster with Jest.
  • Here is how you can make them even faster with setupTestBed :-)Following official guide you define TestBed.configureTestingModule inside beforeEach and get the testing module reseted on each it block in the file.
  • In our case we got tests run 3.5x times faster.
  • People reported 8x and more speed up.You achieve the best results if you combine it with Shallow component tests with NO_ERRORS_SCHEMAHere is how you can setup it with jest-preset-angular.
  • Import setupTestBed.ts in jest.setup.tsand create index.d.tsNow you can with setupTestBed and move it out of beforeEach block, like this:

Michal Pierzchala’s jest-preset-angular makes Angular tests faster with Jest. Here is how you can make them even faster with setupTestBed 🙂 Following official guide you define TestBed…

Faster Angular tests with setupTestBedMichal Pierzchala’s jest-preset-angular makes Angular tests faster with Jest. Here is how you can make them even faster with setupTestBed :-)Following official guide you define TestBed.configureTestingModule inside beforeEach and get the testing module reseted on each it block in the file. This is expensive, especially if you have many dependencies.You can avoid it with beforeAll and afterAll using Brad Chen setupTestBed helper function. In our case we got tests run 3.5x times faster. People reported 8x and more speed up.You achieve the best results if you combine it with Shallow component tests with NO_ERRORS_SCHEMAHere is how you can setup it with jest-preset-angular. Import setupTestBed.ts in jest.setup.tsand create index.d.tsNow you can with setupTestBed and move it out of beforeEach block, like this:

Faster Angular tests with setupTestBed – selleo – Medium