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

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

Open
artbindu opened this issue Sep 20, 2022 · 3 comments

Comments

@artbindu
Copy link

artbindu commented Sep 20, 2022

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:

  • I am trying to configure the .nycrc.json in such a way that, individual files should be covered 65% at least and the overall report should be covered 80%.

  • As the consolated report doesn't pass the 80% then it automatically throws an error in the terminal. In a similar way if the individual file doesn't cover the 65% coverage then it should throw an error like "Single file don't cover in the file: file_name".

  • So, in .nycrc.json there I want to add two configurations (consolidated coverage & individual coverage) like:

// 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.

@artbindu artbindu changed the title istanbuljs / nyc test coverage report validation along with individual files with different configuration Feature Request: 🙏🏼 istanbuljs / nyc test coverage report validation along with individual files with different configuration 🙏🏼 Jan 30, 2023
@artbindu artbindu changed the title Feature Request: 🙏🏼 istanbuljs / nyc test coverage report validation along with individual files with different configuration 🙏🏼 Feature Request: istanbuljs / nyc test coverage report validation along with individual files with different configuration 🙏🏼 Jan 30, 2023
@mahanthi-arun-kumar
Copy link

@artbindu did you get any solution for this?

@artbindu
Copy link
Author

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

@varunrajasekhar
Copy link

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

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

3 participants