Last active
May 22, 2018 17:47
-
-
Save kedar9444/e84478cc92f631a11fdec805a396a202 to your computer and use it in GitHub Desktop.
configuration file, conman for all spec files.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Reconfigures current test suit to prevent angular components compilation after every test run. | |
* Forces angular test bed to re-create zone and all injectable services by directly | |
* changing _instantiated to false after every test run. | |
* Cleanups all the changes and reverts test bed configuration after suite is finished. | |
* reference : https://blog.angularindepth.com/angular-unit-testing-performance-34363b7345ba | |
*/ | |
import { getTestBed, TestBed, ComponentFixture } from '@angular/core/testing'; | |
import { } from 'jasmine'; | |
export const configureTestSuite = () => { | |
const testBedApi: any = getTestBed(); | |
const originReset = TestBed.resetTestingModule; | |
TestBed.resetTestingModule(); | |
TestBed.resetTestingModule = () => TestBed; | |
afterEach(() => { | |
testBedApi._activeFixtures.forEach((fixture: ComponentFixture<any>) => fixture.destroy()); | |
testBedApi._instantiated = false; | |
}); | |
afterAll(() => { | |
TestBed.resetTestingModule = originReset; | |
TestBed.resetTestingModule(); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment