Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

194
Visualizações
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?

over 4 years ago · Santiago Trujillo
1 Respostas
Responde à pergunta

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);
over 4 years ago · Santiago Trujillo Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda