I am testing an Angular2 component and want to assert the component's nativeElement property, but there is no typescript definition for it. My test is as follows:
beforeEach( () => {
myComponentFixture = TestBed.createComponent(MyComponent);
myComponent = myComponentFixture.componentInstance;
});
it('Should display something', fakeAsync(() => {
myComponentFixture.detectChanges();
expect(myComponentFixture.nativeElement.textContent).toContain('something');
}));
The problem is that after I type nativeElement., there is no IntelliSense for it, because I think there are no typings for nativeElement. There are more properties that I can check as innerHtml, id, etc. This test example may not make sense, but I can test some specific properties of the DOM element withmyComponentFixture.debugElement.query(By.css('#myElement')).nativeElement
source
share