I am new to unit testing and I have a component in my project which in its constructor a method is being called
export class myComponent {
constructor(){
this.someMethod();
}
public someMethod(){
//some code
}
I want to test if the method is being called with this test suite:
it('should call for the someMethod', () => {
spyOn(component, 'someMethod') //also tried .and.callThrough();
expect(component.someMethod).toHaveBeenCalled();;
});
The problem is while with my debugging I can make sure the method is being called, the test will always fail.
would really appreciate it, if someone help.