[英]ReferenceError: spyOnProperty is not defined
it('should update treatment instruction data in UI', async(() => {
const spy = spyOnProperty(appService.treatmentInstruction, 'next',
'get').and.returnValue(treatmentInst);
component.updateTemplateInUI();
fixture.whenStable().then(() => {
expect(component.structuresInfo.length).toBe(2);
expect(component.oarStructureLength).toBe(4);
expect(component.notesArray.length).toBe(2);
});
}));
ReferenceError: spyOnProperty is not defined 运行测试用例时出现错误。
我想监视我的服务中存在的治疗指令 BehaviorSubject,如下所述:
treatmentInstruction = new BehaviorSubject(this.myGlobalVar);
currentTreatmentInstruction = this.treatmentInstruction.asObservable();
在jasmine 2.6.0上添加了spyOnProperty
,请确保您满足该要求。
由于jasmine
是karma-jasmine
的依赖,因此更新karma-jasmine
。 看起来在该库的旧版本上, jasmine
被添加为对等依赖项,因此您可以自行决定安装正确版本的jasmine
。
按照“ @ types / jasmine”:“〜2.8.3”,“ jasmine-core”:“〜2.8.0”,
我有这个问题,更新茉莉花版本没有帮助。 问题出在 jshint,在您的测试目录中,您必须修改您的 .jshuntrc 文件:在“globals”中:{ add =>“spyOnProperty”:false
为我工作
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.