The Angular Testing utilities include the TestBed class and helper functions from the test libraries - @angular/core/testing.
The TestBed class is one of the principal Angular testing utilities!
The TestBed class is responsible for configuring and initializing the environment that we are going to write our tests in by calling TestBed.configureTestingModule.
The TestBed.configureTestingModule is used to define the environment that we want our component under test to live in.
The Angular Testing utility APIs are –
1. getTestBed
2. async
3. fakeAsync
4. tick
5. inject
6. discardPeriodicTasks
7. flushMicrotasks
8. ComponentFixtureAutoDetect
The most important static methods are –
1. configureTestingModule
2. compileComponents
3. createComponent
4. overrideModule
5. overrideComponent
6. overrideDirective
7. overridePipe
8. get
9. initTestEnvironment
10. resetTestEnvironment
beforeEach(() => { fixture = TestBed.configureTestingModule({ declarations: [YourComponent ] }) .createComponent(YourComponent); });
References
-