it('should update treatment instruction data in UI', async(() => {
const spy = spyOnProperty(appService.treatmentInstruction, 'next',
'get').and.returnValue(treatmentInst);
ponent.updateTemplateInUI();
fixture.whenStable().then(() => {
expect(ponent.structuresInfo.length).toBe(2);
expect(ponent.oarStructureLength).toBe(4);
expect(ponent.notesArray.length).toBe(2);
});
}));
ReferenceError: spyOnProperty is not defined error is ing 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();
it('should update treatment instruction data in UI', async(() => {
const spy = spyOnProperty(appService.treatmentInstruction, 'next',
'get').and.returnValue(treatmentInst);
ponent.updateTemplateInUI();
fixture.whenStable().then(() => {
expect(ponent.structuresInfo.length).toBe(2);
expect(ponent.oarStructureLength).toBe(4);
expect(ponent.notesArray.length).toBe(2);
});
}));
ReferenceError: spyOnProperty is not defined error is ing 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();
Share
Improve this question
asked Jan 11, 2019 at 6:49
Nilesh GuptaNilesh Gupta
812 silver badges9 bronze badges
10
-
that should be
spyOn
– quirimmo Commented Jan 11, 2019 at 6:54 - spyOn is for installing spy on function. I want to spyOn on service property of type Observable. – Nilesh Gupta Commented Jan 11, 2019 at 6:58
- What is the version of jasmine you are using? – Rakesh Makluri Commented Jan 11, 2019 at 7:01
- "karma-jasmine": "~1.1.1", – Nilesh Gupta Commented Jan 11, 2019 at 7:02
- Upgrade to latest version, it should work. – Rakesh Makluri Commented Jan 11, 2019 at 7:08
3 Answers
Reset to default 3spyOnProperty
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
.
Upgrade following "@types/jasmine": "~2.8.3", "jasmine-core": "~2.8.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
发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744853884a4597289.html
评论列表(0条)