Angular 8 Interview Questions and Answers
Ques 31. Explain the purpose of zone.js in Angular.
Zone.js is a library that helps Angular with change detection. It provides a context for JavaScript execution and allows Angular to know when asynchronous operations, such as HTTP requests or timers, are completed. This knowledge triggers the change detection process.
Example:
import 'zone.js/dist/zone';
Ques 32. What is the Angular TestBed used for in testing?
The TestBed in Angular testing is a configuration and testing utility that provides methods for configuring and creating testing modules. It is used to create a controlled environment for testing Angular components, services, and other constructs.
Example:
TestBed.configureTestingModule({
declarations: [AppComponent],
providers: [DataService],
});
Most helpful rated by users: