【发布时间】:2014-08-17 15:10:12
【问题描述】:
我有一个文件夹结构类似的项目
项目
|--网络
|----脚本
|--------应用
|--------feature.js
|------库
|--------测试
|--------规格
|---------spec.js
|--------karma-conf.js
在我的 karma-conf.js 中,我将覆盖预处理器指向 ../App/feature.js 但这给了我一个空白的覆盖报告,说明“没有数据可显示”。
我尝试了其他一些路径配置,但没有成功。 Karma 文档指出路径应该相对于基本路径。由于遗留原因,我无法移动测试文件夹。
下面是我的 karma-conf.js 的副本
如果您能深入了解这些路径如何用于 karma-coverage,我将不胜感激。
module.exports = function (config) {
config.set({
hostname: 'localhost',
// base path, that will be used to resolve files and exclude
basePath: '',
// frameworks to use
frameworks: ['jasmine'],
// list of files / patterns to load in the browser
files: [
{
pattern: '../App/feature.js',
watched: true,
served: true,
included: true
},
{
pattern: 'Specs/spec/*.js',
watched: true,
served: true,
included: true
}
],
// test results reporter to use
// possible values: 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress','coverage'],
// web server port
port: 6789,
// enable / disable colors in the output (reporters and logs)
colors: true,
// level of logging
// possible values: config.LOG_DISABLE || config.LOG_ERROR || config.LOG_WARN || config.LOG_INFO || config.LOG_DEBUG
logLevel: config.LOG_DEBUG,
// enable / disable watching file and executing tests whenever any file changes
autoWatch: true,
// Continuous Integration mode
// if true, it capture browsers, run tests and exit
singleRun: true,
preprocessors: {
'**/.html': [],
'**/*.coffee': [],
"../App/feature.js": "coverage"
}
});
};
【问题讨论】:
-
我在 Karma 中的路径也遇到了一些问题...您是否尝试将
base/附加到路径中。它从规范内部对我有用