伊斯坦布尔代码覆盖:如何忽略这样的行?
当执行代码覆盖时,我所有的.catch()语句都被发现了,有没有一种方法可以指定/ * istanbul忽略next * / somewhere?
例如:
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); });