July 2017
Intermediate to advanced
384 pages
8h 23m
English
We want to test a component called SectionComponent with just one property username. The component has the following markup:
<label for="username">Username:</label><input id="username" name="username" type="text" pInputText [(ngModel)]="username"/>
In the test file section.component.spec.ts, we will assign the value James Bond to the property username and then check whether the value appears in the view. The full listing of the test code is shown here:
import {TestBed, async, ComponentFixture} from '@angular/core/testing';import {By} from '@angular/platform-browser';import {DebugElement} from '@angular/core';import {SectionComponent} from './section.component';import {FormsModule} from '@angular/forms';describe('Component: ...
Read now
Unlock full access