javascript - Can you have multiple spyObjs in a beforeEach -
i testing angular 1 application jasmine. question is, is possible create 2 spies 2 separate services in same beforeeach
statement?
right can first spy work, i'm not sure why other spy isn't working. have spies setup promise assigned global variable inside of them, can accessed in of tests. so, second variable returning undefined
instead of expected promise.
here sample set code inside beforeeach
:
mockworkingservice = jasmine.createspyobj('mockworkingservice', ['retrieve']); mockworkingservice.retrieve.and.callfake(function(crit) { workingservicedfr = $q.defer(); // $q defined globally return workingservice.promise; }); mockfailingservice = jasmine.createspyobj('mockfailingservice', ['retrieve']); mockfailingservice.retrieve.and.callfake(function(crit) { failingservicedfr = $q.defer(); return failingservice.promise; });
also, retrieve
defined separately each service.
the short answer "yes", can have multiple spies in beforeeach
statements.
Comments
Post a Comment