Skip to content Skip to sidebar Skip to footer

Return A Promise In Jasmine Directive Controller

In my unit test i need to return a promise so that my tests don't fail: describe('refugeeRegister', function () { var controller, scope, rootScope, window; beforeEach(functio

Solution 1:

For hard-coded static resolution it may be

this.signup = jasmine.createSpy("signup").and.returnValue($q.resolve('...');

For dynamic resolution a new promise should be issued on each call:

this.signup = jasmine.createSpy("signup").and.callFake(function () {
  return $q.resolve(...);
});

Post a Comment for "Return A Promise In Jasmine Directive Controller"