Unit Testing in Angular

Automated tests are an important ingredient in a successful project. This course will teach you everything you need to know to unit test your Angular projects, including testing services, component templates, and dealing with asynchronous code.
Course info
Rating
(91)
Level
Beginner
Updated
Sep 6, 2018
Duration
3h 20m
Table of contents
Course Overview
Course Introduction
Isolated Unit Tests
Shallow Integration Tests
Deep Integration Tests
Testing DOM Interaction and Routing Components
Advanced Topics
Description
Course info
Rating
(91)
Level
Beginner
Updated
Sep 6, 2018
Duration
3h 20m
Description

Angular gives us an amazing set of tools to help us unit test our code, but all those tools and techniques need to be learned. In this course, Unit Testing in Angular, you will learn how to effectively unit test your Angular code. First, you will learn to write isolated tests to quickly and easily test services, pipes, and components. Next, you will explore integration tests, used to test your components with their templates. Then, you will see how to deal with advanced topics like asynchronous code. Finally, and most importantly, you will know what it means to write effective, maintainable unit tests. When you are finished with this course, you will feel confident in your ability to write good unit tests for your Angular projects.

About the author
About the author

Joe has been a web developer for the last 13 of his 16+ years as a professional developer. He has specialized in front end and middle tier development . Although his greatest love is writing code, he also enjoys teaching and speaking about code.

More from the author
Angular Crash Course
Intermediate
58m
Nov 1, 2018
More courses by Joe Eames
Section Introduction Transcripts
Section Introduction Transcripts

Course Overview
Hi there. I'm Joe Eames, and welcome to my course, Unit Testing in Angular. I'm a Google developer expert in Angular and have been working with AngularJS since 2010 and Angular since it was in alpha. Angular is an amazing, modern, highly performant framework, and learning it one of the best things that you can do for your career. But it's no good to write code if your code doesn't work. That's where unit testing comes in. In this course we're going to learn all the tools and techniques to effectively unit test Angular projects. Some of the things we will cover are isolated tests for quick and easy testing of components, services, and pipes, integration tests for testing components with their templates, and dealing with asynchronous code in your tests. We'll also see how to write good, maintainable tests. By the time we're through, we'll understand the tools that Angular provides for unit testing your code, how to test your projects effectively, and how to make those tests maintainable. Before starting this course, you should be familiar with JavaScript and Angular. I hope you'll join me on this journey to learn how to unit test Angular with the Unit Testing in Angular course at Pluralsight.

Shallow Integration Tests
Hello, I'm Joe Eames, and welcome to this module on Shallow Integration Tests. Integration tests let us test not only a component, but its template as well. This could be a huge benefit when working to assure that your components actually do what they're supposed to do. In this module we will be learning how to do integration tests with Angular, which gives us a way to test a component with its template. We'll start by looking at the TestBed, which is the main testing tool provided by Angular. After that, we'll look at how to ignore child directives in our shallow integration tests, then we'll look at how to test out templates, which is the core reason for writing integration tests. Finally, we'll look at how to deal with child components and directives, instead of ignoring them.

Deep Integration Tests
Hello, I'm Joe Eames, and welcome to this module on deep integration tests. In this module we will be learning how to do deep integration tests, which gives us a way to test our components with their live children. We'll start by jumping right into writing a deep integration test. This will not be too much more difficult than what we've actually been doing with our shallow integration tests. Then we'll see a technique for locating child directives, and finally, we'll take a bit of time looking at how to use integration tests with services to get some unique benefits.

Testing DOM Interaction and Routing Components
Hello, I'm Joe Eames, and welcome to the module on Testing DOM Interaction and Routing Components. In this module we'll start by looking at how to trigger events in our components. We'll actually look at three different methods for accomplishing this in a test. After that we'll see how to interact with input boxes. And the final thing we'll cover in this module is routing components. We'll look at dealing with two aspects here. First, we'll see how to test components that use the activated route service and then we'll look at testing components that use the RouterLink directive, and how to test that they are set up correctly.

Advanced Topics
Hello, I'm Joe Eames, and welcome to the module on Advanced Topics. We'll cover two main topics in this module. First, we'll see how to deal with asynchronous code in our tests. With observables in Angular this isn't as common of a need as it used to be, but it can still come into play. Second, we'll see how to use the CLI to generate code coverage reports. Both of these techniques can be very valuable if used appropriately.