Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
artbindu opened this issue Dec 9, 2022 · 2 comments

Comments

@artbindu
Copy link

artbindu commented Dec 9, 2022

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%'?

@pocesar
Copy link
Owner

pocesar commented Dec 9, 2022

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

@artbindu
Copy link
Author

artbindu commented Jan 30, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants