我正在使用Angular CLI版本1.4.5及以下是Karma.conf.ts文件
module.exports = function (config) {
config.set({
basePath: '',
exclude: [
"src/app/components/panel/panel.component.spec.ts",
"src/app/components/accordion/accordion.component.spec.ts"
],
frameworks: ['jasmine', '@angular/cli'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter'),
require('@angular/cli/plugins/karma')
],
client:{
clearContext: false
},
coverageIstanbulReporter: {
reports: [ 'html', 'lcovonly' ],
fixWebpackSourcePaths: true
},
angularCli: {
environment: 'dev'
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.DEBUG,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false
});
};
,我什至在tsconfig.spec.json文件中添加了排除,以排除以选择这些文件进行测试。
{
.....,
"include": [
"**/*.spec.ts",
"**/*.d.ts"
],
"exclude": [
"app/components/panel/panel.component.spec.ts",
"app/components/accordion/accordion.component.spec.ts"
]
}
这是缺少用于排除的东西吗?
更改src/test.ts
中的配置。
const context = require.context('./', true, /.spec.ts$/);
https://github.com/angular/angular-cli/issues/9026#issuecomment-354475734