Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
Get value of span tag in jasmine angular2 testing

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?

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

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);
about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!