Fixing the tests and understanding TestBed
To better understand the use of TestBed
, we’ll fix the rest of our project’s tests by adding dependencies to the test files. We’ll start with the app.component.spec.ts
file and make the fixes as follows:
describe('AppComponent', () => { Â Â beforeEach(async () => { Â Â Â Â await TestBed.configureTestingModule({ Â Â Â Â Â declarations: [AppComponent], Â Â Â Â Â imports: [RouterTestingModule], Â Â Â }).compileComponents(); Â Â }); Â Â it('should create the app', () => { Â Â Â Â const fixture = TestBed.createComponent(AppComponent); Â Â Â Â const app = fixture.componentInstance; Â Â Â Â expect(app).toBeTruthy(); Â Â }); });
In this test, we cleaned up the test cases that had already been created by the Angular CLI when we started the project....