title: Assertion error when testing async function with mocha and chaiAsPromised
body: <p>So i am trying to test that my async function throws an error when I stub <code>s3GetObject = Promise.promisify(s3.getObject.bind(s3))</code> to be rejected with <code>blah</code> however i am getting that my function is not async and it does not throw an error.</p>
  
  <p>below is my <code>main.js</code> file with the <code>tests.js</code> of this:</p>
  
  <pre><code>const Promise = require('bluebird');
  const AWS = require('aws-sdk');
  
  const s3 = new AWS.S3({
  });
  
  const s3GetObject = Promise.promisify(s3.getObject.bind(s3));
  
  async function getS3File(){
    try {
      const contentType = await s3GetObject(s3Params);
      console.log('CONTENT:', contentType);
      return contentType;
    } catch (err) {
      console.log(err);
     throw new Error(err);
    }
  };
  </code></pre>
  
  <p>Testing:</p>
  
  <pre><code>    /* eslint-env mocha */
  const rewire = require('rewire');
  const chai = require('chai');
  const sinonChai = require('sinon-chai');
  const sinon = require('sinon');
  const chaiAsPromised = require('chai-as-promised');
  
  chai.should();
  chai.use(sinonChai);
  chai.use(chaiAsPromised);
  
  describe('Main', () =&gt; {
  
    describe('getFileFromS3', () =&gt; {
      let sut, getS3File, callS3Stub;
  
      beforeEach(() =&gt; {
        sut = rewire('../../main');
        getS3File = sut.__get__('getS3File');
        sinon.spy(console, 'log');
      });
  
      afterEach(() =&gt; {
        console.log.restore();
      });
  
      it('should be a function', () =&gt; {
        getS3File.should.be.a('AsyncFunction');
      });
  
      describe('with error', () =&gt; {
        beforeEach(() =&gt; {
          callS3Stub = sinon.stub().rejects('blah');
          sut.__set__('s3GetObject', callS3Stub);
          getS3File = sut.__get__('getS3File');
        });
  
        it('should error with blah', async () =&gt; {
          await getS3File.should.throw();
          //await console.log.should.be.calledWith('blah');
  
        });
      });
    });
  });
  </code></pre>
  
  <p>The errors I am getting are:
    1) Main</p>
  
  <blockquote>
    <p>getFileFromS3
             should be a function:
         AssertionError: expected [Function: getS3File] to be an asyncfunction
          at Context.it (test\unit\main.spec.js:28:27)</p>
  </blockquote>
  
  <p>2) Main</p>
  
  <blockquote>
    <p>getFileFromS3
         with error
           should error with blah:  AssertionError: expected [Function: getS3File] to throw an error</p>
    
    <p>UnhandledPromiseRejectionWarning: Error: blah
    UnhandledPromiseRejectionWarning: Unhandled promise rejection.</p>
  </blockquote>
  
  <p>This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with <code>.catch(). (rejection id: 228)</code></p>