Html 是否有Angular8测试方法来查找嵌套组件实例?
我有一个角度8应用程序。我正在使用当前模板测试Html 是否有Angular8测试方法来查找嵌套组件实例?,html,angular,typescript,angular-test,Html,Angular,Typescript,Angular Test,我有一个角度8应用程序。我正在使用当前模板测试MyCustomComponent: <mat-card> <table> <another-custom-component></another-custom-component> </table> </mat-card> 但是在我的fixture.debugElement.childNodes中的这个示例中,我只能找到一个节点,即MatCard
MyCustomComponent
:
<mat-card>
<table>
<another-custom-component></another-custom-component>
</table>
</mat-card>
但是在我的fixture.debugElement.childNodes
中的这个示例中,我只能找到一个节点,即MatCard
如何得到嵌套的孩子?
我想我可以试着用递归函数找到想要的子对象,但是有内置的方法吗?对于每个指令,你应该有单独的描述,对于每个描述,你可以有不同的描述。您应该在其父级中一次测试一个子级,因此一次测试所有子级树是一种反模式。是的,我同意,但为了确保下一个子级从grand X Parents获得正确的参数,您可以从getElement().componentInstance获得参数,并测试值和其他属性
fixture.debugElement.queryAll(By.directive(AnotherCustomComponent))