I am writing unit-test cases using mocha, istanbul & nyc.
I am trying to check the coverage report should be 80% overall in .nycrc.json
.
{
"statements": 80,
"branches": 80,
"functions": 80,
"lines": 80
}
If the consolated report is not covered 80% then throw an error in the terminal.
Now, my question: is there any way to check individual files 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 are two configurations like:
// consolated coverage validation
{
"statements": 80,
"branches": 80,
"functions": 80,
"lines": 80
}
// individual files coverage validation with some another 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, to check if someone adds a new unit-test file then its coverage report should check in run time. I am trying to add such type of configuration.
I didn't see such configuration here: istanbuljs/nyc