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....