【问题标题】:Istanbul code coverage : how to ignore such lines?伊斯坦布尔代码覆盖率:如何忽略这些行?
【发布时间】:2017-05-08 10:20:31
【问题描述】:

在执行代码覆盖时,我的所有 .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
  }

【问题讨论】:

    标签: node.js code-coverage istanbul


    【解决方案1】:

    是的,只需将 .catch(e =&gt; next(e)); 更改为

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-07-02
      • 1970-01-01
      • 2015-08-26
      • 2019-04-28
      • 2015-07-29
      • 2015-09-10
      • 2016-07-22
      相关资源
      最近更新 更多