Angular2 @Viewchild unit test
I have a component like this:
export class ParentComponent implements OnInit, OnDestroy {
@ViewChild(ChildComponent) childComponent: ChildComponent;
}
which uses childComponent
to make the call, let's say:
this.childComponent.method();
inside the method ParentComponent
.
So, when I try to test a method ParentComponent
that internally uses childComponent
, childComponent is returned as undefined.
How to solve a problem?
+6
source to share