Here is my html code
<span class="boxText">
{{model.number}}
<i *ngIf="model.canText" class="fa fa-comment" placement="right"></i>
</span>
There is only one span tag in my code. I want to test if span tag contains the specific value, i.e model.number.
Here I am able to get the span element.
let el = fixture.debugElement.query(By.css('.boxText'));
let spanEl = el.nativeElement;
But not able check if the value exist. How do i do this using jasmine?
I leave here the answer for someone else, but it was just accessing the element as on plain js.
let el = fixture.debugElement.query(By.css('.boxText'));
let spanEl = el.nativeElement;
// spanEl.innerHTML => give you the value
and test like normally
expect(spanEl.innerHTML).toContain(component.model.number);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With