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

137
Visualizações
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.

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

0

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

about 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