1
叫我是新来的单元测试和我在我的项目中的组件,它在其构造方法被调用刺探的方法,它正在从组件的构造
export class myComponent {
constructor(){
this.someMethod();
}
public someMethod(){
//some code
}
我希望测试该方法被调用这个测试套件:
it('should call for the someMethod',() => {
spyOn(component, 'someMethod') //also tried .and.callThrough();
expect(component.someMethod).toHaveBeenCalled();;
});
问题是当我调试我可以确保该方法被调用,测试总会失败。
会真的很感激它,如果有人帮助。