Testing reactive forms
As we saw in Chapter 8, Orchestrating Validation Experiences in Forms, forms are an integral part of an Angular app. It is rare for an Angular app not to at least have a simple form , such as a search form. We have already learned that reactive forms are better than template-driven forms in many ways, and are easier to test, so in this section, we are going to focus only on testing reactive forms.
Consider the following component that behaves like a search form:
search.component.ts
import { Component } from '@angular/core'; import { FormControl, FormGroup, Validators } from '@angular/forms'; @Component({ selector: 'app-search', template: ` <form [formGroup]="searchForm" (ngSubmit)="search()"> <input type="text" ...