pocesar/grunt-mocha-istanbul

coverage global threshold validation in grunt-mocha-istanbl is not working properly.

Opened this issue · 2 comments

In my code structure, there are multiple directories under src, and there is one directory test which contains unit test files.
My mocha_istanbul configuration as follows:

mocha_istanbul: {
    coverage: {
        src: ['src/test/**/*'],
        options: {
            excludes: [
                '*.test.*'
            ],
            coverage: true,
            coverageFolder: './reports',
            mochaOptions: ['-r', './babel-register.js', '--exit'],
            print: 'both',
            root: './src',
            check: {
                statements: 80,
                branches: 80,
                functions: 80,
                lines: 80
            },
            reportFormats: ['cobertura', 'lcov']
        }
    }
}

After executing the file , Coverage Summary as follows:

=============================== Coverage summary ===============================
Statements   : 81.32% ( 7319/9002 )
Branches     : 89.69% ( 3555/5331 )
Functions    : 86.01% ( 1506/1751 )
Lines        : 87.02% ( 7095/8757 )
================================================================================

But it's still throwing errors for global threshold validation and error as follows:

/Users/user/grunt-mocha-istanbul-project/node_modules/istanbul/lib/cli.js:38
        throw ex; // turn it into an uncaught exception
        ^
ERROR: Coverage for statements (75.02%) does not meet global threshold (80%)
(Use `node --trace-uncaught ...` to show where the exception was thrown)

But our coverage statement already covered 81.32%.
Then why is global threshold validation showing '75.02%'?

do you have .test. files together with other files in your /src folder?

Previous Structure

src: contains all application codes
test: contains unit test files of src/**/* folders

But now I move all unt-test (.*test*) files into the src directory and put test files like

And also see the same issue. @pocesar