Wednesday, 10 May 2017

node mocha Istanbul code coverage: line marked as uncovered even if branch is tested

In my user.controller.js , I have a list function in which the User model list is called list

    function list(req, res, next) {
      const { limit = 50, skip = 0 } = req.query;
      User.list({ limit, skip })
        .then(users => res.json(users))
        .catch(
          /* istanbul ignore next */
          (e) => {
            next(e);
          });
    }

user.model.js

    119  list({ skip = 0, limit = 50 } = {}) {
    120    return this.find()
    121      .sort({ createdAt: -1 })
    122      .skip(skip)
    123      .limit(limit)
    124      .exec();
    125   }
    126. };

running Istanbul code coverage, I don't understand why the line 119 is marked as 'uncovered' ..

        File |% Stmts |% Branch |% Funcs |% Lines |Uncovered Lines |
user.model.js|    100 |      40 |    100 |    100 |            119 |

I tried to insert a /* istanbul ignore next */ before the faulty line wo any success, I also tried to insert it inside the block before the return... no way.. same uncovered line..

subsidiary question on it : if the branch% is 40% , is there any way to display a list of the uncovered branches ?

thanks for feedback



via erwin

No comments:

Post a Comment