Angular2 testing: What's the difference between a DebugElement and a NativeElement object in a ComponentFixture?
nativeElement
returns a reference to the DOM elementDebugElement
is an Angular2 class that contains all kinds of references and methods relevant to investigate an element or component (See the source of DebugNode and DebugElement
to add on to what has been mentioned already :
abstract class ComponentFixture { debugElement; // test helper componentInstance; // access properties and methods nativeElement; // access DOM detectChanges(); // trigger component change detection}
Take a look at Angular discussion about this topic and related PR.
Mainly:
fixture.componentInstance == fixture.debugElement.componentInstance;fixture.nativeElement == fixture.debugElement.nativeElement;