/ / Jest:コードカバレッジの行を無視 - code-coverage、jestjs、istanbul

Jest:コードカバレッジ、コードカバレッジ、jestjs、istanbulの行を無視する

Jestでは、テストカバレッジのコードを無視する方法はありますか? 使ってみた

/* istanbul ignore next */

しかし、うまくいかないようです。

回答:

回答№1は4

できます。

(function(global) {

var defineAsGlobal = true;
/* istanbul ignore next */
if(typeof exports === "object") {
module.exports = lib;
defineAsGlobal = false;
}
/* istanbul ignore next */
if(typeof modules === "object" && typeof modules.define === "function") {
modules.define("lib", function(provide) {
provide(lib);
});
defineAsGlobal = false;
}
/* istanbul ignore next */
if(typeof define === "function") {
define(function(require, exports, module) {
module.exports = lib;
});
defineAsGlobal = false;
}
/* istanbul ignore next */
defineAsGlobal && (global.lib = lib);
})(this);

サンプルプロジェクト https://github.com/ilyar/sandbox/tree/master/jest