Reputation: 272
I want my jenkins build should break when code coverage does not meet defined threshold in karma.config.js. Karma should return non-zero error code to break continuous integration if code coverage does not meet with defined threshold. But in my case it exit with zero error code and thus causing non failure of tests if code coverage is less than threshold.
Angular CLI: 6.0.8
Angular: 6.1.9
Karma: 1.7.1
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage'),
reports: ['html', 'lcovonly'],
fixWebpackSourcePaths: true,
thresholds: {
statements: 80,
lines: 80,
branches: 80,
functions: 80
}
}
I am executing the below command :
ERROR [reporter.coverage-istanbul]: Coverage for branches (70.7%) does not meet global threshold (80%)
ERROR [reporter.coverage-istanbul]: Coverage for functions (79.05%) does not meet global threshold (80%)
Karma to return non-zero error code if code coverage does not meet threshold to break continuous integration
Karma spits out an error but exits like normal with zero as error code
"Commands like ng test
, ng serve
and ng build --watch
that run in watch mode don't usually exit with an error. This is by design.
Non-watch commands like ng test --watch=false
, ng build
and ng e2e
do exit with an error code though.
Also It can't seem to get both autowatch turned off and code coverage generated at the same time"
If anyone has any recommendations as to how I can fix this, or if anyone has any ideas about what I might be doing wrong please let me know.
Upvotes: 3
Views: 2271
Reputation: 2632
There was an issue on Github that addressed this exact issue and this issues already got closed by this PR.
Upvotes: 0