lundi 29 août 2016

Mock method of an instance variable of an angular service in jasmine

In essence I want to create a spy object of something of the like:

myService.myVariable.get()

However, I can't seem to mock it properly. If i try

 myServiceMock = jasmine.createSpyObj("myService", ["myVariable"]);

Then I get that .get() is undefined for it. Similarly

 myServiceMock = jasmine.createSpyObj("myService", ["myVariable.get"]);

Then I get that myVariable is undefined in the test

I'm not looking at all to test the service, I just want to be able to intercept that call. In the component being tested, the line calling this is

myService.myService.get({.....});

Aucun commentaire:

Enregistrer un commentaire