我正在尝试测试最终调用 GetRole 函数的 SetRole 函数,但我无法覆盖代码覆盖率中的行。请指导我测试级联函数、嵌套函数、函数中的函数。
组件.ts
SetRole(inp){
this.role = inp;
this.GetRole()
}
尝试这个:
it('SetRole',() => {
const inp = 'dummyInput';
const spy = spyOn(component,'GetRole')
component.SetRole(inp)
expect(spy).toHaveBeenCalled()
});
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句