Ionic 2 アプリの単体テストの作成に取り組んでおり、次のような @ViewChild 呼び出しがあります。
<ion-slides #slides (ionSlideDidChange)="onSlideChanged()" pager>
そして私のslides.tsにはこれがあります:
@ViewChild(Slides) slides: Slides;
これは、サーバーの実行時には問題なく機能し、スライドはうまく機能しますが、単体テストを作成しようとすると、スライドが未定義になります。もちろん、これは他のすべてを壊します。
私の単体テストのセットアップは次のようになります。
beforeEach(async(() => TestUtils.beforeEachCompiler([HomePage]).then(compiled => {
fixture = compiled.fixture;
component = compiled.instance;
component.ngOnInit();
})));
it('should have a defined component', () => {
// The next line is where it starts throwing the errors.
fixture.detectChanges();
expect(component).toBeDefined();
});
単体テストで @ViewChild を正しく定義するにはどうすればよいですか?