每个测试运行正常但是,根据功能我必须在我的注册组件中使用标头组件,因此我们知道在angular2到用户其他组件视图与其他组件视图我们必须在HTML中包含它的选择器。所以,我已经包含了我的标题<custom-header-component></custom-header-component>
并且功能正常运行但不知怎的,我的每个测试规范都在错误
Chrome 53.0.2785(Linux 0.0.0)注册组件无法注册 FAILED [1]错误:错误 dist / dev / src / app / shared / header / header.component.html:11:28引起: 无法读取属性&#39; root&#39; of undefined [1] TypeError:无法读取 财产&#39; root&#39; undefined [1]用法:spyOn(,) [1]错误::找不到要侦察的对象进行注册() [1] Chrome 53.0.2785(Linux 0.0.0)注册组件无法执行 注册失败[1]错误:错误 dist / dev / src / app / shared / header / header.component.html:11:28引起: 无法读取属性&#39; root&#39; of undefined [1] TypeError:无法读取 财产&#39; root&#39;未定义[1]用法:spyOn(,)
以下是我的组件模板的示例:
<custom-header-component></custom-header-component>
<div id="" class="pages">
<div class="space-y pattern-bg share-y">
<div class="container padding-y">
<div class="row">
<div class="col-md-12">
<div class="quform-outer">
<div class="quform-inner">
<div class="quform-elements">
<div class="row">
<div class="col-md-6">
<div class="socialshareimages" (click)="signupFacebook()">
<img src="../../../assets/images/fblogin.jpg"
width="335" height="61">
</div>
</div>
<div class="col-md-6">
<div class="socialshareimages" (click)="signupTwitter()">
<img src="../../../assets/images/twlogin.jpg"
width="335" height="61">
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>