if you have for example
class TestedComponent() {
@ViewChild('ChildComp') public variableChildComponent: ChildComp;
}
:
beforeEach(() => {
TestBed.configureTestingModule({
declarations: [ TestedComponent, ChildComp]
})
fixture = TestBed.createComponent(TestedComponent);
comp = fixture.componentInstance;
spyOn(TestedComponent.variableChildComponent, 'someMethod').and.returnValue(true);
});