Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 341
Scipion Avatar asked Oct 18 '22 04:10

Scipion


1 Answers

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.

like image 50
Estus Flask Avatar answered Oct 20 '22 20:10

Estus Flask