1

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

  • Because of your use of default arguments you need to test all four cases: `list()`, `list({})`, `list({ skip: 1 })`, and `list({ limit: 1 })`. – idbehold Jun 04 '17 at 18:32
  • thanks a lot... Did not know about ir –  Jun 06 '17 at 06:08

0 Answers0