我的覆盖率数字始终显示为0/0和100%。我找到了一些链接指向错误报告和文档,但没有帮助。
这是我的配置文件
module.exports = function (config) {
config.set({
// base path that will be used to resolve all patterns (eg. files, exclude)
basePath: '../../..',
// frameworks to use
// available frameworks: https://npmjs.org/browse/keyword/karma-adapter
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
"./CloudConnect.PE.TheApp/Static/CloudConnect.Web.Shared/js/common.js",
"./CloudConnect.PE.Test/node_modules/angular-mocks/angular-mocks.js",
"./CloudConnect.PE.TheApp/Static/CloudConnect.Web.Shared/js/bridge/browser.min.js",
{ pattern: "./CloudConnect.PE.TheApp/Static/CloudConnect.Web.Shared/js/bridge/**/*.js", watched: false, included: false },
{ pattern: "./CloudConnect.PE.TheApp/Static/CloudConnect.Web.Shared/css/**/*.css", watched: false, included: true, served: true },
{ pattern: "./CloudConnect.PE.TheApp/Static/CloudConnect.Web.Shared/images/*.*", watched: false, included: false, served: true },
"./CloudConnect.PE/static/cloudconnect.pe/js/shared.js",
"./CloudConnect.PE.Test/Client/ActWeb/tests/init.spec.js", // always load init.spec.js
"./CloudConnect.PE.ActWeb/static/CloudConnect.PE.ActWeb/js/app.js",
"./CloudConnect.PE.Test/Client/ActWeb/tests/**/*.spec.js"
],
// preprocess matching files before serving them to the browser
// available preprocessors: https://npmjs.org/browse/keyword/karma-preprocessor
preprocessors: {
"./CloudConnect.PE.ActWeb/static/cloudconnect.pe.actweb/js/app.js": ["coverage"]
},
// test results reporter to use
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'coverage'],
coverageReporter: {
type: 'html',
dir: './CloudConnect.PE.Test/Client/coverage/ActWeb'
}
});
};
我不得不删除一些配置,所以SO会让我发布。显然我必须在我的帖子中使用完整的配置编写很多代码。
答案 0 :(得分:1)
虽然路径本身不区分大小写,但文件路径和预处理器路径需要完全匹配。
我通过改变它来实现它:
preprocessors: {
"./CloudConnect.PE.ActWeb/static/cloudconnect.pe.actweb/js/app.js": ["coverage"]
}
到这个
preprocessors: {
"./CloudConnect.PE.ActWeb/static/CloudConnect.PE.ActWeb/js/app.js": ["coverage"]
}
答案 1 :(得分:0)
有关使用istanbul-instrumenter-loader设置webpack的所有说明都没有。
{
test: /\.ts/,
include: helpers.root('src', 'app'),
loader: 'istanbul-instrumenter-loader',
enforce: 'post'
}