Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/29.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
Angular 角度-如何测试子组件是否接收到正确的属性?_Angular_Jasmine - Fatal编程技术网

Angular 角度-如何测试子组件是否接收到正确的属性?

Angular 角度-如何测试子组件是否接收到正确的属性?,angular,jasmine,Angular,Jasmine,使用此html: <app-parent> <app-child name="john" age="12"></app-child> </app-parent> 但这并不是最好的方式。我们可以这样说: <app-parent> <app-child [name]="name" [age]="age"></app-child&

使用此html:

<app-parent>
    <app-child name="john" age="12"></app-child> 
</app-parent>

但这并不是最好的方式。

我们可以这样说:

<app-parent>
  <app-child [name]="name" [age]="age"></app-child>
</app-parent>


我只想确保
component.name
component.age
具有准确的值,而不测试子组件是否接收到正确的值,因为Angular已经测试了父组件到子组件的绑定。我们应该只测试我们的代码,而不是Angular的实现/代码。

准确地说。我不是要测试角度,而是测试我是否正确地通知了属性。使用我告诉过的方法是可行的,但它看起来不是最好的方法——那就像e2e测试一样,对吗
<app-parent>
  <app-child [name]="name" [age]="age"></app-child>
</app-parent>