Reputation: 428
Hi I am trying to test a div text which is dynamically bind with interpolation. The data I am receiving is from API on ngOnInit()
. How can I do proper test on that ?
Right now I am getting error - Error: Expected '' to equal undefined
Spec:-
it('should check store name' , () => {
const mypara: HTMLDivElement = fixture.debugElement.nativeElement.querySelector('.ant-tag-red');
expect(mypara).toBeTruthy();
expect(mypara.innerHTML).toEqual(component.name);
})
HTML :-
<div class="ant-tag-red">{{name}}</div>
Component : name: any
Upvotes: 0
Views: 2799
Reputation: 1968
Try this line instead:
const mypara = fixture.debugElement.query(By.css('.ant-tag-red'));
expect(mypara.nativeElement.innerText).toEqual(component.name);
Upvotes: 1