簡體   English   中英

ReferenceError:未定義 spyOnProperty

[英]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 ,請確保您滿足該要求。

由於jasminekarma-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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM