伊斯坦布尔代码覆盖率:如何忽略这些行?
Istanbul code coverage : how to ignore such lines?
执行代码覆盖时,我所有的 .catch() 语句都被覆盖了,有没有办法在某处指定 /* istanbul ignore next */
?
例如:
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
}
是的,只需将 .catch(e => next(e));
更改为
.catch(
/* istanbul ignore next */
(e) => {
next(e);
});
执行代码覆盖时,我所有的 .catch() 语句都被覆盖了,有没有办法在某处指定 /* istanbul ignore next */ ?
例如:
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
}
是的,只需将 .catch(e => next(e));
更改为
.catch(
/* istanbul ignore next */
(e) => {
next(e);
});