July 2017
Intermediate to advanced
454 pages
10h 1m
English
In this section, we will learn about testing Angular services.
In most Angular applications, writing services is an important and core aspect as it performs the interactions with backend services; creating and sharing data between components and are easy to maintain in the long run. Hence, it's equally important to make sure that we are testing our Angular services thoroughly.
Let's learn how to write test scripts for testing our services. In order to test a service, let's first create a service using the ng command.
Run the following command in your terminal:
ng g service ./test-app/test-app
The preceding command will generate the test-app.service.ts and test-app.service.spec.ts files in the test-app folder.
Read now
Unlock full access