Testing Forms
Explore how to test reactive forms in Angular by writing unit tests that verify form control values, button states, and submit events. Understand how to trigger DOM events and use test utilities for efficient form validation in your applications.
We'll cover the following...
We will learn how to test Angular forms. Previously, we learned that forms are an integral part of an Angular application. It is rare for an Angular application 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 will focus on only testing reactive forms.
Testing the form input
Consider the following search.component.ts file:
In the preceding component, we can write our unit tests to verify that: ...