我想从测试范围中排除所有component.ts文件,并仅覆盖任何级别的子文件夹中的service.ts文件。 我尝试了下面的代码段中注释掉的许多选项,但是没有一个对我有用。 寻求专家的帮助以实现我的目标。
module.exports = function (config) {
config.set({
files: [
// '**/*.service.ts'
],
basePath: '',
frameworks: ['jasmine', '@angular-devkit/build-angular'],
plugins: [
require('karma-jasmine'),
require('karma-coverage'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular-devkit/build-angular/plugins/karma')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(__dirname, '../coverage/new-tts-ui'),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'coverage'],
preprocessors: {
//'**/*.service.ts': ['coverage']
//'**/*!(component).js' : ['coverage']
// '**/*.service.ts': ['coverage']
},
port: 9876,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true,
//exclude: ['/**/*.component.ts','/**/*.component.js']
//exclude: ['src/*/{*.js,!(src)/**/*.service.ts}']
exclude: ['**/*.component.ts', '**/*.component.js']
});
};