Testing the components

Components are the centerpiece of Angular. They are the nucleus around which the rest of the framework is built. We'll explore what a component is, why it is important, and how to test it.

Our testing strategy revolves around verifying the correctness of the properties and methods of the classes that make up the components.

When writing unit tests for components, we initialize the component and inject any dependencies manually rather than bootstrapping the application.

The TestBed function will be used for testing the component, which is the main entry to all of Angular's testing interface. It will enable us to create our components for use in running unit tests.

TestBed is the primary API for writing unit tests for ...

Get TypeScript 2.x for Angular Developers now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.