Grouping the istanbul code coverage report by folder

I run a code coverage report for NodeJ using istanbul and the nyc command.

I use mocha for my unit tests

I get a report for each file, as expected, but I would like to see a report containing a single directory summary. Let me explain in more detail that I get poems that I would like to see

All my source files are in one folder, and I would like to see a summary of this one folder instead of a complete list of all the files in this folder

This is what my folder structure looks like

// This is the folder where all the sources are at 
src
    // This is the folder where coverage is output
    coverage
        NodeJs
            index.html
    file1.js
    file2.js
    file3.js
    // This is the folder where all tests are at
    tests
        test_file1.js
        test_file2.js
        test_file3.js

My file .babelrclooks like this

{
    "presets": ["es2015", "stage-2"],
    "plugins": [
        [
            "istanbul",
            {"exclude": ["**/tests/*.js"]}
        ]
    ]
}

I use the following command to run my coated tests

node ./node_modules/.bin/nyc --reporter=html \
    --report-dir=./src/coverage/NodeJs \
    ./node_modules/mocha/bin/_mocha \
    --require babel-core/register \
    --ui bdd src/tests/test*.js

, , src/coverage/NodeJs/index.html . :

Coverage report for all files

, , - - , , , , :

Coverage report for single folder

, . ... .babelrc exclude .babelrc, 2 (src src/tests),

Coverage report with two folders

, , ... , . , , HTML.

, ? ( , , )

+8

Source: https://habr.com/ru/post/1681057/


All Articles