title: TypeError: undefined is not a constructor in jasmine unit test with angularjs
body: <p>I am having above error in my Jesmine tests. Code has a Controller which calls AppsService service to receive a promise response of array of apps followed by onLoad method -</p>
  
  <pre><code>AppsService.initAndGetApps(appCredentialType)
          .then(onLoad)
          .catch(onError);
  </code></pre>
  
  <p>Code works fine but getting error for unit tests like -</p>
  
  <blockquote>
    <p>TypeError: undefined is not a constructor (evaluating 'AppsService.initAndGetApps(appCredentialType).then(onLoad)')</p>
  </blockquote>
  
  <p>I tried mocking initAndGetApps in my spec file with Jasmine &amp; also as custom method like this (both are giving same above error) -</p>
  
  <p>1.</p>
  
  <pre><code>initAndGetApps : jasmine.createSpy("initAndGetApps").and.callFake(function (credentialType) {
      return [];  // empty is ok
  }
  </code></pre>
  
  <p>2.     </p>
  
  <pre><code>AppsService = {
      initAndGetApps: function (credentialType) {
          return []; 
      }
  }
  
  $provide.value('AppsService', AppsService);
  </code></pre>
  
  <p>AppsService uses deferred.promise to return promise response after doing some computation based on credentialType parameter (It also does two Promise calls). Test is not able to call initAndGetApps as not getting console of credentialType at first line of initAndGetApps.</p>
  
  <p>Can someone guide me the right way to mock AppsService.</p>