title: ES6 Istanbul code coverage : how to test correctly a branch
body: <p>I don't understand how the test coverage is processing this .catch() branch :</p>
  
  <pre><code>  newUser.save()
      .then((savedUser) =&gt; {
        res.json(savedUser);
      })
      .catch(
        (e) =&gt; {
          if (e.name === 'ValidationError' &amp;&amp; e.errors.username.kind === 'unique') {
            res.status(409);
            res.json({ error: { message: 'Existing user', field: e.errors.username.path, value: e.errors.username.value } });
          } else {
            /* istanbul ignore next */
            next(e);
          }
        });
  </code></pre>
  
  <p>I am testing correctly the first block:</p>
  
  <p>if (e.name === 'ValidationError' &amp;&amp; e.errors.username.kind === 'unique') {...)</p>
  
  <p>and I don't have a test for the second else block, so I added an ignore next statement :</p>
  
  <p>else {
         /* istanbul ignore next */
          next(e);
     }</p>
  
  <p>the code code coverage reports the line 58. ( if..) as uncovered..</p>
  
  <pre><code> |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
  -|----------|----------|----------|----------|----------------|
   |      100 |    93.75 |      100 |      100 |             58 |
  </code></pre>
  
  <p>but the following test is executing correctly, covering this line ...</p>
  
  <pre><code>      describe('# POST /api/v1/users', () =&gt; {
          it('should NOT create a duplicated user', () =&gt; {
            return request(app)
              .post('/api/v1/users')
              .set('Authorization', superAdminJwtToken)
              .send(newUser)
              .expect(httpStatus.CONFLICT)
              .then((res) =&gt; {
                expect(res.body.error.message).to.equal('Existing user');
                expect(res.body.error.field).to.equal('username');
                expect(res.body.error.value).to.equal(newUser.username);
              });
          });
        });
  </code></pre>