From the course: Angular: Building Large Applications

Unlock the full course today

Join today to access over 24,800 courses taught by industry experts.

Unit testing with Jasmine and Karma

Unit testing with Jasmine and Karma - Angular Tutorial

From the course: Angular: Building Large Applications

Unit testing with Jasmine and Karma

- [Instructor] So let's take a look at unit testing in Angular using Jasmine and Karma. Unit tests are essential for verifying that individual pieces of your code, like components, services, and pipes, work as expected. In Angular, Jasmine is a behavior driven testing framework used for writing tests. While Karma is the test runner that executes these tests in real browsers. They are pre-configured when you create a new Angular project using the Angular CLI. So you don't need to set anything up. So let's start by taking a look at the test setup in the app component. So you can find it in the exercise files or in the project that we started together. So you can click on Source, App, and then app.component.spec.ts. I'm going to drop this file inside of my yes code here, which is my favorite editor. So when you create a component, Angular automatically generates a corresponding test file. So here's an example of a basic test setup in the app.component. So the first thing it does, there's…

Contents