title: How Do I Test nested ES6 Generators using Mocha?
body: <p>I'm trying to use <code>co-mocha</code> to test some nested generators functionality in my <code>koa</code> app.  The class works just fine at runtime, but when I attempt to test the functionality, I cannot get the nested generator to run in my test.</p>
  
  <p><strong>Class being tested:</strong></p>
  
  <pre><code>import Promise from 'bluebird'
  
  class FooService {
    _doAsync(){
      return new Promise((resolve) =&gt; {
        setTimeout(() =&gt; {
          resolve({
            foo: 'FOO'
          })
        }, 500)
      })
    }
  
    create(){
      console.log('This never gets logged')
      let self = this
      return function*(){
        console.log(`This doesn't either`)
        return yield self._doAsync()
      }
    }
  }
  export default new FooService()
  </code></pre>
  
  <p><strong>Test File</strong></p>
  
  <pre><code>import fooService '../services/foo-service'
  import Chai from 'chai'
  let expect = Chai.expect
  
  describe('Testing generators', () =&gt; {
    it('Should just work', function *(){
      console.log('This log never happens')
      let result = yield fooService.create()
      expect(result).to.equal({foo: 'FOO'})
    })
  })
  </code></pre>
  
  <p>I'm running mocha w/ <code>--require co-mocha</code> and Node 4.2.6</p>
  
  <p>While the tests complete w/o errors, NONE of the console above ever get logged and so I'm quite sure the actual test generator is never running at all.</p>
  
  <p>If I try using the npm package, <code>mocha-generators</code> instead, while I get the log from inside the test generator, the underlying generator returned from the <code>create()</code> method on the service never fires... </p>
  
  <p>What am I doing wrong??</p>