When testing an Angular service, why might you use a spy?
- To create a new instance of the service
- To mock dependencies used by the service
- To secretly record user interactions
- To simulate service method calls
In Angular testing, you use a spy to mock dependencies used by the service being tested, allowing you to control and observe interactions with those dependencies.
Loading...
Related Quiz
- When you want a component to render content into its template from outside, you use a _____.
- How can you dynamically add form controls in reactive forms?
- In an Angular reactive form, how can you dynamically add a validator to a form control at runtime?
- How do you create a custom pipe in Angular?
- You have a component that fetches and displays user data. You want to ensure that if the component is destroyed, the subscription to the Observable fetching the data is also terminated. How would you achieve this?