Service tests
As we studied in detail in Chapter 5, Angular Services and the Singleton Pattern, the service that works as a repository of business rules in an Angular application. Consequently, it is crucial for us to develop unit tests for these services. In this section, we will focus on the ExerciseSetsService
service to illustrate the Angular unit testing techniques in our project. Let’s begin.
In the exercise-sets.service.spec.ts
test file, let’s start by fixing the tests automatically created by the Angular CLI that are not running correctly:
import { TestBed } from '@angular/core/testing'; import { ExerciseSetsService } from './exercise-sets.service'; import { HttpClientTestingModule } from '@angular/common/http/testing'; fdescribe('ExerciseSetsService', () => { let service: ExerciseSetsService; let httpMock: HttpTestingController; beforeEach...