Below unit test is throwing error : TypeError: Cannot read property 'toString' of undefined. How can this be resolved?
component.Ts code
//Input value from parent
@Input() path: treeDataKey;
ngOnInit() {
this.getTestPlanData(this.testId);
this.testPath = (this.path).toString().replace(/,/g,' /');
}
getTestPlanData(param:any) {
//Do something
}
component.spec.ts
it('should call getTestPlanData', () => {
expect(component.getTestPlanData).toHaveBeenCalled;
});