Testing Angular components
We have just seen how to test a service in Angular application. Now, let's discuss testing an Angular component. Perform the following steps to create AppComponent for the application:
- Create a file named 
app.component.ts. 
- Import modules such as 
Component,TodoService, andTodothat are necessary for theAppComponent, as shown: 
        import { Component } from '@angular/core'; 
        import { Todo } from './todo'; 
        import { TodoService } from './todo.service'; - Define the 
AppComponentclass, as demonstrated: 
        export class AppComponent {} - Decorate the 
AppComponentclass by the@Componentattribute with theselector,providersandtemplateUrlmetadata: 
        @Component({ 
            selector: 'my-app', 
            templateUrl: './app.component.html', 
            providers: [TodoService] 
        }) 
        export class AppComponent {     
        } - Declare the 
todos,todoService,newTodoText, andtitlevariables: 
todos: Array<Todo>...