We an angular app that is tested like this:
ng test --code-coverage --watch=false --karma-config karma.conf.ci.js
With the karma.conf.ci.js:
module.exports = function (config) {
const puppeteer = require('puppeteer');
process.env.CHROME_BIN = puppeteer.executablePath();
let testResultFolder = require('path').join(__dirname, '../../../angular-test');
config.set({
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage'),
require('@angular-devkit/build-angular/plugins/karma'),
require('karma-junit-reporter'),
],
client: {
jasmine: {
},
clearContext: false, // leave Jasmine Spec Runner output visible in browser
},
jasmineHtmlReporter: {
suppressAll: true, // removes the duplicated traces
},
coverageReporter: {
dir: require('path').join(testResultFolder, './coverage'),
subdir: '.',
reporters: [{ type: 'html' }, { type: 'text-summary' }, { type: 'cobertura' }],
},
junitReporter: {
outputDir: require('path').join(testResultFolder, './results'),
},
reporters: ['progress', 'kjhtml', 'junit'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['ChromeHeadless'],
singleRun: true,
restartOnFileChange: true,
});
};
I would like to exclude some kind of classes from the code coverage, to only watch the code that we want to test. Typically, we would like to exclude all the Modules(*.module.ts
) because there is no logic in this.
The goal is to enforce an high % of code coverage in the PR, not inlfuenced by code we don't want to test.