大佬教程收集整理的这篇文章主要介绍了angular – 使用spyon时的代码覆盖率问题,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
这是我的测试用例,
it('Should Invoke onNext function',async(() => { const fixture = TESTBed.createComponent(LoginComponent); fixture.detectChanges(); const login = fixture.componenTinstance; spyOn(login,'onNext'); let email = fixture.debugElement.nativeElement.querySELEctor("input[name='username']"); email.value = "email"; let nextButton = fixture.debugElement.nativeElement.querySELEctorAll("button")[1]; nextButton.click(); fixture.whenStable().then(() => { expect(login.onNext).toHaveBeenCalled(); }) }));
正如你所看到的那样,我正在监视onNext函数,以验证是否在Nextbutton click上调用它.它工作正常,测试通过.
但是我的“登录”页面的代码覆盖率报告显示未涵盖onNext函数.
我究竟做错了什么??
如果我不监视onNext函数,该函数也会被覆盖,async(() => { const fixture = TESTBed.createComponent(LoginComponent); fixture.detectChanges(); const login = fixture.componenTinstance; let email = fixture.debugElement.nativeElement.querySELEctor("input[name='username']"); email.value = "email"; let nextButton = fixture.debugElement.nativeElement.querySELEctorAll("button")[1]; nextButton.click(); }));
以上是大佬教程为你收集整理的angular – 使用spyon时的代码覆盖率问题全部内容,希望文章能够帮你解决angular – 使用spyon时的代码覆盖率问题所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。