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

155
Vistas
Count the number of child components by tag name in angular2 unit testing

I have a parent component which will dynamically insert the child components based on the length of array. I want to test the number of components created, by using its tag name.

<div *ngFor = "let item of phoneList; let i = index">
    <phone-item [item]="item"> </phone-item>
</div>

I want to verify the number of <phone-item></phone-item> created within the html template in angular2 unit testing.

I have very little knowledge on debugElement and nativeElement. This is what I have tried to do.

let el = fixture.debugElement.query(By.css('phone-item'));

But I want the count of child components created.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

Use DebugElement#queryAll which returns an array. query only returns the first matching

over 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