title: Configure a stubbed factory that returns a promise from a deferred in a unit test?
body: <p>I am writing an AngularJs unit test where I need to stub out a factory that returns a promise when invoked. I will later resolve the promise manually in my tests by using a locally scoped deferred object.</p>
  
  <p>I am trying to do</p>
  
  <pre><code>  let currentUser
    beforeEach(module(($q, $provide) =&gt; {
      currentUser = $q.defer()
      $provide.factory('gettingCurrentUser', () =&gt; currentUser.promise)
    }))
  </code></pre>
  
  <p>But this will not work since it seems like <code>$q</code> cannot be injected into a <code>module</code> block. Of course if I change it to an <code>inject</code> block, <code>$provide</code> is no longer injectable!</p>
  
  <p>I can hack around this issue a dozen different ways, but it seems too straightforward to be an edge case that requires hacking.</p>
  
  <p>What is the "correct AngularJs" way of doing this?</p>