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.
Use DebugElement#queryAll which returns an array. query
only returns the first matching
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With