Karma-coverage显示分支覆盖0/0

时间:2016-10-09 03:31:54

标签: javascript unit-testing karma-runner karma-jasmine karma-coverage

我的Karma覆盖率显示语句,功能和线路覆盖的正确值,但是对于分支覆盖率始终显示0/0。我有近23个spec文件,所有这些文件都是一样的。附上报告的屏幕截图。

这是我的业力配置文件。

module.exports = config => config.set(
    client: {
        package,
        specs: package + '/test/specs'
    },
    singleRun: false,
    frameworks: ['jasmine'],
    browsers: ['PhantomJS'/*, 'Firefox', 'Chrome'*/],
    reporters: ['progress', 'junit', 'kjhtml', 'coverage'],
    files: [
        __dirname + '/../sinon.js',
        'packages/requirejs/require.js',
        __dirname + '/../testLoader.js',
        {pattern: 'test/**/*', included: false},
        {pattern: 'packages/**/*.js', included: false},
        {pattern: 'build/dist/**/*.js', included: false}
    ],
    proxies: {
        ['/base/packages/' + package + '/test/']: '/base/test/',
        ['/base/packages/' + package + '/']:      '/base/build/dist/'
    },
    middleware: ['config'],
    plugins: [
        'karma-*',
        {
            'middleware:config': ['value', (req, res, next)=>req.url.endsWith('config.json') ? res.end('{}') : next()]
        }
    ],
    junitReporter: {
        outputDir: 'build/reports/junit/',
        useBrowserName: false,
        outputFile: 'test-results.xml'
    },
    preprocessors: {
      // source files, that you wanna generate coverage for
      // do not include tests or libraries
      // (these files will be instrumented by Istanbul)
      'test/spec/*.js': ['coverage']
    },
    // optionally, configure the reporter
    coverageReporter: {
      type : 'html',
      dir : 'coverage/'
    }

);

Karma coverage report

0 个答案:

没有答案