ES6代码覆盖nyc / mocha为什么这条线被标记为未覆盖?即使有趣也是

时间:2017-06-04 17:27:56

标签: node.js code-coverage istanbul nyc

我想知道为什么这条ES6线被标记为无遮盖:

的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
  }

结果报告:

------|----------|----------|----------|----------|----------------|
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();
  }
  ....

运行此方法,因为console.log显示消息:

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

感谢您的反馈

0 个答案:

没有答案