Scipion
Scipion

Reputation: 11888

Angular4 difference componentInstance and debugElement.componentInstance

I just went through the doc over there https://angular.io/guide/testing

component = fixture.debugElement.componentInstance
component = fixture.componentInstance

But I am yet to understand the difference between these two

Upvotes: 5

Views: 1649

Answers (1)

Estus Flask
Estus Flask

Reputation: 222603

There is no difference. TestBed.createComponent creates an instance of component class, both properties refer to it:

fixture.debugElement.componentInstance === fixture.componentInstance

fixture.componentInstance can be preferred because it takes less time to type.

Upvotes: 3

Related Questions