Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda