
Angular Cookbook
By :

While you can provide stubs for your services in the unit tests with Jest, sometimes, it might feel like an overhead creating a mock for every new service. Let's suppose that if the service's usage is limited to one test file, it might make more sense to just use spies on the actual injected service. In this recipe, that's exactly what we're going to do.
The project for this recipe resides in chapter10/start_here/using-spies-on-injected-service
.
npm install
to install the dependencies of the project.npm run test
.This should run the unit tests on the console using Jest. You should see something similar to the following output:
Figure 10.8 – Unit tests failing for the 'using-spies-on-injected-service' project
Now that we have the tests running locally...