Istanbul code coverage : how to ignore such lines?

user762579 picture user762579 · May 8, 2017 · Viewed 13.2k times · Source

when performing code coverage , all my .catch() statements are uncovered, is there a way to specify /* istanbul ignore next */ somewhere ?

ex :

 function list(req, res, next) {
  const { limit = 50, skip = 0 } = req.query;
  User.list({ limit, skip })
    .then(users => res.json(users))
    .catch(e => next(e)); <= this line is marked as uncovered
  }

Answer

FieryCod picture FieryCod · May 9, 2017

Yep it is, just change .catch(e => next(e)); to

.catch(
/* istanbul ignore next */
(e) => { 
  next(e);
});