title: Unit testing generators with `return` and `yield`
body: <p><strong>Given this function</strong></p>
  
  <pre><code>function* backflip(query) {
    return yield 123;
  }
  </code></pre>
  
  <p><strong>And this test</strong></p>
  
  <pre><code>describe('backflip', () =&gt;
    it('should do that ^', () =&gt;
      let handlerInstance = handler();
      expect(handlerInstance.next().value).to.equal(123);
      expect(handlerInstance.next().done).to.equal(true);
    );
  );
  </code></pre>
  
  <p>Istanbul, should say all branches are covered, but in fact this covers 3 of 4. Removing <code>return</code> fixes the problem. </p>
  
  <ul>
  <li>Is <code>return</code> and <code>yield</code> together an antipattern?</li>
  <li>Is this a bug?</li>
  </ul>
  
  <p><strong>For context, Babel compiles this as</strong></p>
  
  <pre><code>"use strict";
  
  var _marked = [backflip].map(regeneratorRuntime.mark);
  
  function backflip(query) {
    return regeneratorRuntime.wrap(function backflip$(_context) {
      while (1) {
        switch (_context.prev = _context.next) {
          case 0:
            _context.next = 2;
            return 123;
  
          case 2:
            return _context.abrupt("return", _context.sent);
  
          case 3:
          case "end":
            return _context.stop();
        }
      }
    }, _marked[0], this);
  }
  </code></pre>