2

我的覆盖率始终显示为 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 会让我发帖。显然我必须在我的帖子中使用完整的配置编写很多代码。

4

2 回答 2

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"]
    }
于 2015-07-16T20:06:56.117 回答
0

所有的说明都缺少关于使用 istanbul-instrumenter-loader 设置 webpack 的内容。

{
    test: /\.ts/,
    include: helpers.root('src', 'app'),
    loader: 'istanbul-instrumenter-loader',
    enforce: 'post'
}
于 2017-06-12T20:15:23.430 回答