You have a directive that changes the background color of an element when the user hovers over it. How would you test this directive to ensure that it behaves correctly?
- Use end-to-end tests
- Use linters
- Use unit tests
- Use visual regression tests
To test this directive, you should use unit tests. Unit tests are suitable for testing the individual behavior of the directive and verifying that it changes the background color on hover as expected.
Loading...
Related Quiz
- How can a parent component communicate with a child component without using @Input or @Output?
- In RxJS, which operator can be used to catch and handle errors in an Observable stream?
- In Angular, the _____ pipe is used to automatically update the view with the latest value emitted by an Observable.
- To check if a form control's value has been changed by the user, you can check the _____ property.
- How can you prevent memory leaks related to observables when using the async pipe in Angular?