template parse error
親で子コンポーネントを使用する場合。親コンポーネントで子コンポーネントを使用中にエラーが発生しました - 角2ユニットテスト(KarmaJasmine)
私は2つのコンポーネントを持っています。
1. CardComponent
2. InfoComponent
マイCardComponentのHTML
<div class="footer">
<full-info></full-info>
</div>
CardComponentのspecファイル:
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [InfoComponent, CardComponent ],
imports: [
FormsModule,
MaterialModule.forRoot()
],
schemas: [ NO_ERRORS_SCHEMA ], //Used CUSTOM_ERRORS_SCHEMA also
})
.compileComponents();
}));
マイInfoComponent TSコード:
import { Component, Input } from '@angular/core';
@Component({
selector: 'full-info',
templateUrl: './full-info.component.html',
styleUrls: ['./full-info.component.css']
})
export class InfoComponent {
public fullInfo;
}
InfoComponent仕様宣言:
beforeEach(async(() => {
TestBed.configureTestingModule({
declarations: [ InfoComponent ],
imports: [
FormsModule,
MaterialModule.forRoot()
],
schemas: [ NO_ERRORS_SCHEMA ]
})
.compileComponents();
}));
これらの2つのコンポーネントのテストケースを実行すると、が個別にになります。
私はその後、私はエラーを取得しています時にこれらのテストケースを実行しています:
'full-info' is not a known element:
1. If 'full-info' is an Angular component, then verify that it is part of this module.
2. If 'full-info' is a Web Component then add "CUSTOM_ELEMENTS_SCHEMA" to the '@NgModule.schemas' of this component to suppress this message. ("
</div>
<div class="footer">
[ERROR ->]<full-info></full-info>
</div>
私も、私はこのエラーを取得していますCardComponent
でInfoComponent
を輸入しています。私は問題を見つけることができません。私は誰にでもそれが私にとって素晴らしいことを知っています。
「CardComponent」と「InfoComponent」を個別にテストすることができます。つまり、 'InfoComponent'ユニット内で' InfoComponent'が意図したとおりに動作していることをテストします。次に、 'CardComponent'テストで、' CardComponent'が意図したとおりに動作していることを確認します。なぜそれらを一緒にテストするのですか?つまり、 'CardComponent'をテストしているときに' InfoComponent'を既にテストしたはずですよね?したがって、それぞれの単体テストが合格すれば、どちらも正しいでしょうか? – SrAxi
@SrAxi個別にテストすることは、それぞれに 'fdescribe'を使ってテストすることを意味します。 'fdescribe'を削除すると、エラーが発生します。 – Dalvik