Unit testing the services
In this section, you will learn how to write unit tests for services. Services are meant to be reused in one or more components. There can be different kinds of services, such as those providing utility APIs, reusable business rules/logic, and data processing tasks (also termed data services) such as retrieving data from the server. Components inject these services via the constructor, and later, use one or more APIs of the injected services to perform different tasks such as sending/retrieving data to/from the server. Externalizing the data handling logic in the services helps the components stay lean and easy to unit test, as the services can be mocked.
In this section, we will learn some of the following aspects ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access