ReferenceError:未定义spyOnProperty

时间:2019-01-11 06:49:22

标签: javascript angular typescript jasmine karma-jasmine

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Extension",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": [
                "--disable-extensions",
                "--extensionDevelopmentPath=${workspaceRoot}"
            ],
            "ns.customSetting": "customValue"
        },
        {
            "name": "Extension with another value",
            "type": "extensionHost",
            "request": "launch",
            "runtimeExecutable": "${execPath}",
            "args": [
                "--disable-extensions",
                "--extensionDevelopmentPath=${workspaceRoot}"
            ],
            "ns.customSetting": "anotherValue"
        }
    ]
}

ReferenceError:未定义spyOnProperty错误正在运行测试用例。

我要监视服务中存在的治疗指令行为主体,如下所述:

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);
    });
}));

2 个答案:

答案 0 :(得分:0)

spyOnProperty是在茉莉2.6.0上添加的,请确保您满足该要求。

由于jasminekarma-jasmine的依赖项,因此更新了它。看起来好像是在该库的旧版本上将jasmine作为peer dependency添加的一样,因此您可以自行安装正确版本的jasmine

答案 1 :(得分:0)

按照“ @ types / jasmine”:“〜2.8.3”,“ jasmine-core”:“〜2.8.0”,