Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 是否有Angular8测试方法来查找嵌套组件实例?_Html_Angular_Typescript_Angular Test - Fatal编程技术网

Html 是否有Angular8测试方法来查找嵌套组件实例?

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

我有一个角度8应用程序。我正在使用当前模板测试
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))