Search⌘ K
AI Features

Writing Tests

Explore how to write unit tests in Angular using the Jasmine framework. Learn to create test suites and specs with describe and it functions, set expectations with expect, and use matchers like toEqual. This lesson helps you understand testing fundamentals without running the tests, focusing on analyzing expected values rather than implementation details.

Let’s write some tests for Adder.

To introduce some of the basics of testing, we’re going to take a look at what our tests for Adder would look like using the Jasmine framework. However, we won’t be running them because for now, our only concern is a baseline understanding of how the tests work. .

We group tests in Jasmine together using a test suite.

Test suite

TypeScript 3.3.4
describe('Adder', () => {
// Tests go here
});
  • describe: We’ll begin our test suite in Jasmine by calling its describe function. This function takes two
...