In the preceding section, you learned how to write test scripts to test our Angular services. In this section, we will write a test script and learn how to mock backend services in real-time projects.
The following are the use cases we will writing our test scripts for:
- Write a test script to test a method in service.
- Write a test script to check whether the return value of the method contains a particular value.
- Write a test script to mock the backend connection using mockBackend and also check whether the target URL is correct.
- Write a test script to set the mockResponse for the request URL.
- Finally, call a method written in service and map the response, which should be equal to the ...