Here is my html code
这是我的HTML代码
<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.
我的代码中只有一个span标记。我想测试span标签是否包含特定值,即model.number。
Here I am able to get the span element.
在这里,我可以获得span元素。
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?
但无法检查值是否存在。我如何使用茉莉花?
1 个解决方案
#1
9
I leave here the answer for someone else, but it was just accessing the element as on plain js.
我留下了别人的答案,但它只是在普通的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);
#1
9
I leave here the answer for someone else, but it was just accessing the element as on plain js.
我留下了别人的答案,但它只是在普通的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);