2
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 error is coming on running test case.

I want to spyOn treatmentInstruction BehaviorSubjectthat is present in my service as mentioned below :

treatmentInstruction = new BehaviorSubject(this.myGlobalVar);
currentTreatmentInstruction = this.treatmentInstruction.asObservable();
Nilesh Gupta
  • 71
  • 2
  • 8

3 Answers3

3

spyOnProperty was added on jasmine 2.6.0, be sure that you fulfill that requisite.

Since jasmine is a dependency of karma-jasmine update that instead. Looks like on old version of this library jasmine was added as a peer dependency so it would be up to you to install the correct version of jasmine.

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
a--m
  • 4,716
  • 1
  • 39
  • 59
1

Upgrade following "@types/jasmine": "~2.8.3", "jasmine-core": "~2.8.0",

Rakesh Makluri
  • 647
  • 4
  • 10
0

I had this issue, updating jasmine version didn't help. The problem came for jshint, in your test directory you must modify your .jshuntrc file : in "globals": { add => "spyOnProperty" : false

Worked for me

Brice B
  • 103
  • 1
  • 1
  • 8