O'Reilly logo

Hands-on Full Stack Development with Angular 5 and Firebase by Uttam Agarwal

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Unit testing an Angular component

In this section, we will write our first Angular test for the login component. The steps involved in writing test cases are as follows:

  1. Identifying the class under test: The first step in writing unit test cases is to identify the dependencies. The login component constructor shows all the dependencies and is dependent on UserService, Router, AuthenticationService, and AngularFireAuth:
constructor(private userService: UserService,         private router: Router,         private authService: AuthenticationService,         private angularFireAuth: AngularFireAuth)
  1. Creating all the mock or stubs classes: Once we identify all the dependencies, we need to eliminate these external dependencies and concentrate only on the component ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required