Component fixture

In our test, we use the createComponent method of the Testbed class to create a new component instance of our dummy component. As a result of that method call, we'll receive a component fixture object that will help us to further perform testing on our component.

The component fixture is a wrapper around our component being tested, which allows us to further inspect and manipulate our test case. We can now use the nativeElement property of the fixture to access the root DOM element of the created component, and to assert on the text content of that element, to verify whether the component has rendered correctly.

Let's look at the ComponentFixture type, and the available properties and methods, in more detail:

Member ...

Get Mastering Angular Components now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.