Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/node.js/40.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/jenkins/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 使用摩卡和伊斯坦布尔时不包括文件_Node.js_Jenkins_Mocha.js_Istanbul - Fatal编程技术网

Node.js 使用摩卡和伊斯坦布尔时不包括文件

Node.js 使用摩卡和伊斯坦布尔时不包括文件,node.js,jenkins,mocha.js,istanbul,Node.js,Jenkins,Mocha.js,Istanbul,使用mocha和instanbul时,如何从覆盖率报告中排除文件夹和文件(按路径) 我想通过配置排除,而不是 /*istanbul ignore next*/ 在每个文件中 (生成的报告由Jenkins使用) 谢谢,您可以使用-x参数忽略与特定模式匹配的文件 istanbul help cover ... -x <exclude-pattern> [-x <exclude-pattern>] one or more fileset pattern

使用mocha和instanbul时,如何从覆盖率报告中排除文件夹和文件(按路径)

我想通过配置排除,而不是

/*istanbul ignore next*/
在每个文件中

(生成的报告由Jenkins使用)


谢谢,

您可以使用
-x
参数忽略与特定模式匹配的文件

 istanbul help cover

 ...
 -x <exclude-pattern> [-x <exclude-pattern>]
        one or more fileset patterns e.g. "**/vendor/**"
 ...
伊斯坦布尔帮助封面 ... -x[-x] 一个或多个文件集模式,例如“**/vendor/**” ...
我会在您的案例中使用以下方法:

istanbul -x "**/pattern/to/exclude/**" cover _mocha -- --recursive -R tap test/ > test.tap && istanbul report clover –  snoof 9 hours ago 

只需添加多个
-x
选项,即可排除多个模式

谢谢你的建议

这就是解决方案:

istanbul cover -x '**/config/**'  _mocha -- --recursive -R tap test/ > test.tap && istanbul report clover

如果运行伊斯坦布尔帮助配置,您将看到伊斯坦布尔的默认配置。您可以将默认配置复制/粘贴到源代码树根目录下的
.伊斯坦布尔.yml
文件中,然后将排除项存储在其中

下面是我的目录(这样可以很容易地排除许多目录):


你如何调用伊斯坦布尔?调用是什么意思?你如何运行伊斯坦布尔?我问这个问题是因为有一个命令行选项可以排除文件。我运行:
istanbul cover\u mocha--recursive-R tap test/>test.tap&&istanbul report clover
如何在配置文件中执行此操作,例如GrunFile?取决于您使用什么grunt库来包装伊斯坦布尔。在
grunt karma
中,我排除了一个文件夹(
app/tests
)如下:
{…,预处理器['app/{*.js,!(tests)/***/*.js}']=['coverage'],…}
您确定排除了包含所有源设置为true的作品吗?插装:root:src include all sources:true verbose:true excludes:[“**/src/client/**”]报告:dir:“coverage”,我仍然在报告中获取客户端文件。
verbose: false
instrumentation:
    root: .
    extensions:
        - .js
    default-excludes: true
    excludes: ['**/tinymce/**', '**/lib/**', '**/tools/**', '**/build/**']
    embed-source: false
    variable: __coverage__
    compact: true
    preserve-comments: false
    complete-copy: false
    save-baseline: false
    baseline-file: ./coverage/coverage-baseline.json
    include-all-sources: true
    include-pid: false
    es-modules: false
reporting:
    print: summary
    reports:
        - lcov
    dir: ./tools/coverage
    watermarks:
        statements: [50, 80]
        lines: [50, 80]
        functions: [50, 80]
        branches: [50, 80]
    report-config:
        clover: {file: clover.xml}
        cobertura: {file: cobertura-coverage.xml}
        json: {file: coverage-final.json}
        json-summary: {file: coverage-summary.json}
        lcovonly: {file: lcov.info}
        teamcity: {file: null, blockName: Code Coverage Summary}
        text: {file: null, maxCols: 0}
        text-lcov: {file: lcov.info}
        text-summary: {file: null}
hooks:
    hook-run-in-context: false
    post-require-hook: null
    handle-sigint: false
check:
    global:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []
    each:
        statements: 0
        lines: 0
        branches: 0
        functions: 0
        excludes: []