Sunday, 4 June 2017

ES6 code coverage nyc/mocha why this line is marked as not covered ? even if fun is run

I would like to know why this ES6 line is marked as non covered:

package.json

....
"test:v1:coverage": "cross-env NODE_ENV=test ./node_modules/.bin/nyc _mocha 
--timeout 15000 --ui bdd  --colors --compilers  js:babel-core/register 
server/v1/tests --recursive",
...
  "nyc": {
    "require": [
      "babel-register"
    ],
    "exclude": [
      "**/server/helpers/tests.utility.js"
    ],
    "sourceMap": false,
    "instrument": false
  }

resulting report :

------|----------|----------|----------|----------|----------------|
File  |  % Stmts | % Branch |  % Funcs |  % Lines |Uncovered Lines |
   ---|----------|----------|----------|----------|----------------|

um.js | 100 | 40 | 100 | 100 | 113 |

user.model.js (um.js)

  ....
  list({ skip = 0, limit = 50 } = {}) {. :: <= line 113
    console.log('USER MODEL LIST');
    return this.find()
      .sort({ createdAt: -1 })
      .skip(skip)
      .limit(limit)
      .exec();
  }
  ....

this method is run, as the console.log display the message:

  # GET /api/v1/users/
  USER MODEL LIST
  Mongoose: users.find({}, { sort: { createdAt: -1 }, skip: 0, limit: 50, fields: {} })

thanks for your feedbacks



via erwin

No comments:

Post a Comment