February 2019
Beginner
694 pages
18h 4m
English
To start off with, we will create a series of tests that will check the internal state of the AppComponent class once instantiated, in a file named src/app/app.component.spec.ts as follows:
describe('/src/app/app.component.spec.ts : AppComponent ', () => {
let fixture: ComponentFixture<AppComponent>;
let app: AppComponent;
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [
AppComponent
],
imports: [
FormsModule,
ReactiveFormsModule
]
}).compileComponents();
fixture = TestBed.createComponent(AppComponent);
app = fixture.debugElement.componentInstance;
}));
});
Here, we have defined our test suite with a beforeEach function. We start our test suite by defining two variables named fixture and app
Read now
Unlock full access