0

这是我的配置文件:

module.exports = function(config) {
    config.set({
        basePath: './',
        autoWatch: true,
        frameworks: ['jasmine'],
        files: [
            '../public_html/libs/mylib/lib.js',
            '../public_html/libs/mylib/utility.js',
            '../public_html/libs/mylib/config/*.js',
            '../public_html/libs/mylib/enumerations.js',
            '../public_html/libs/mylib/apiComm.js',
            '../public_html/libs/mylib/baseObject.js',
            '../public_html/libs/mylib/book.js',
            '../public_html/libs/mylib/file.js',
            '../public_html/libs/mylib/library.js',
            '../public_html/libs/mylib/publishing.js',
            '../public_html/libs/mylib/topic.js',
            '../test/*Spec.js'
        ],
        reporters: ['progress', 'coverage'],
        preprocessors: {
            '../public_html/libs/mylib/topic.js': ['coverage']
        },
        port: 9876,
        colors: true,
        browsers: ['Chrome'],
        captureTimeout: 60000,
        singleRun: false
    });
};

每当我运行karma start config/karma.config.js它时,它都会运行单元测试并coverage在正确的位置创建文件夹。但是,它将 topic.js.html 文件转储到与 topic.js 相同的目录中。为什么?

4

2 回答 2

3

我知道这是迟到的回复,但它也可能对其他人有所帮助。

将您的配置文件上移一个文件夹并将“../public_html”更改为“public_html”

我刚刚处理完这件事。

是的,你需要拥有...

coverageReporter: {
     type : 'html',
     dir : 'coverage/'
}

...正如 Acosta 所说,但您在编写报告文件时还指示伊斯坦布尔进入一个目录,然后进入该public_html文件夹。如果 karma.conf.js 文件与 app 和 test 文件夹位于同一文件夹中,那么您的报告应该呈现在正确的位置。

于 2014-08-21T15:02:09.937 回答
1

你需要添加coverageReporter,

   coverageReporter: {
         type : 'html',
         dir : 'coverage/'
   }

O 你也可以添加记者的集合

   coverageReporter: {
        reporters: [
          //{ type: 'html', dir: 'TestOutputFolder/' },
          { type: 'text-summary', dir: 'TestOutputFolder/' },
          { type: 'cobertura', dir: 'TestOutputFolder/' }
        ]
    },
于 2014-03-28T16:22:04.723 回答