title: Stubbing functions with Sinon and Promises
body: <p>I have some file <code>mainFile</code> that uses a method <code>helperMethod</code>, which is a method that returns a Promise in a file <code>helperFile</code>. How do I stub what gets returned from <code>helperMethod</code>?</p>
  
  <p>Here's what I have so far - </p>
  
  <p>helperFile:</p>
  
  <pre class="lang-js prettyprint-override"><code>export function helperMethod() {return a Promise}
  module.exports.helperMethod = helperMethod;
  </code></pre>
  
  <p>mainFile:</p>
  
  <pre class="lang-js prettyprint-override"><code>import helperMethod from helperFile;
  
  methodInMainFile() {console.log(helperMethod);}
  </code></pre>
  
  <p>mainFileTest:</p>
  
  <pre class="lang-js prettyprint-override"><code>import methodInMainFile from mainFile;
  import * as utils from helperFile;
  
  sinon
    .stub(utils, 'helperMethod')
    .returns(Promise.resolve(madeUpResponse));
  methodInMainFile();
  </code></pre>
  
  <p>The above piece of code prints <code>Promise { undefined }</code>. How do I get it to print <code>Promise { madeUpResponse }</code>? I don't think helperMethod is actually getting called (as it shouldn't be) since I logged something there and it never shows.</p>