istanbuljs / nyc

the Istanbul command line interface
https://istanbul.js.org/
ISC License
5.55k stars 353 forks source link

Feature Request: istanbuljs / nyc test coverage report validation along with individual files with different configuration 🙏🏼 #1491

Open artbindu opened 1 year ago

artbindu commented 1 year ago

Feature Request: istanbuljs / nyc test coverage report validation along with individual files with different configuration 🙏🏼

This is not an issue, needs some confirmation about nyc configuration. I am writing unit-test cases using mocha, istanbul & nyc.

If we try to check the overall coverage report should cover 80% then .nycrc.json configuration as follows:

{
      "statements": 80,
      "branches": 80,
      "functions": 80,
      "lines": 80
}

And if any coverage is not covered 80% then it is throwing an error in the terminal.


Now, my question: is there any way to check individual files should cover some coverage reports? ()

For example:

// consolated coverage validation: Check Over all report: already implemented
{
      "statements": 80,
      "branches": 80,
      "functions": 80,
      "lines": 80
}
// individual files coverage validation with some other config
{
      "statements": 65,
      "branches": 65,
      "functions": 65,
      "lines": 65
}

This is my .nycrc.json file:

{
        "cache": false,
        "check-coverage": true,
        "extension": [".js"],
        "include": ["src/**/*.js"],
        "exclude": ["src/**/*.test.js"],
        "reporter": [
            "lcov",
            "text",
            "text-summary",
            "cobertura"
        ],
        "report-dir": "unittest_report",
        "statements": 80,
        "branches": 80,
        "functions": 80,
        "lines": 80,
        "watermarks": {
            "statements": [70, 90],
            "branches": [70, 90],
            "functions": [70, 90],
            "lines": [70, 90]
        }
}

I am trying to add this validation in nyc config like watermarks for individual files and if the individual files don't cover 65% then it should throw an error or show a warning end of the report.

mahanthi-arun-kumar commented 1 year ago

@artbindu did you get any solution for this?

artbindu commented 1 year ago

@mahanthi-arun-kumar No, I did not see anyupdate reguarding this in the istanbul/nyc documentation.

varunrajasekhar commented 6 months ago

Me too!! Looking for a fix... sadly found nothing :(