开玩笑:忽略代码覆盖的行 [英] Jest: Ignore lines for code coverage

查看:685
本文介绍了开玩笑:忽略代码覆盖的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Jest中,有什么方法可以忽略测试覆盖率的代码吗? 我尝试使用

In Jest, is there any way to ignore code for test coverage? I tried using

/* istanbul ignore next */

但这似乎不起作用.

推荐答案

有效.

(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/开玩笑

这篇关于开玩笑:忽略代码覆盖的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆