javascriptmocha.jschairollupjscoveralls

Coveralls test percentage reduced by _typeof function


I've got an NPM package that uses Coveralls. My percentage is at 85% and I can see that the last 15% has to do with the following func:

function _typeof(obj) {
  if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") {
    _typeof = function (obj) {
      return typeof obj;
    };
  } else {
    _typeof = function (obj) {
      return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj;
    };
  }

  return _typeof(obj);
}

I assume this func is generated by Rollup because it is not in my src file.

Do I have to write tests for 'generated' code I haven't written my self? or is there some way to ignore this func.

Test command: istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage


Solution

  • I would propose the following.

    If that doesn't work (You aren't able to locate the _typeof function by looking at the coverage report) you could try the following: