吞咽-业力建议一个外部配置文件如下:
module.exports = {
basePath: '',
singleRun: true
};我想要一个像这样的外部配置文件(咕噜-业力式):
module.exports = function(config) {
config.set({
basePath: '',
singleRun: true
});
};如何使用proper config file与业力API。
详细信息:
我正在使用吞咽业力,正如提到的there,我必须自己实现它.
Karma API非常简单:
var server = require('karma').server;
server.start(config, done);config变量是模糊的。它是一个带有configuration的普通对象。
var config = {
basePath: '',
singleRun: true
// ...
}让我们来看一看咕哝的业力:
样本咕噜-业力配置:
karma: {
unit: {
configFile: 'karma.conf.js'
}
}格伦特-业力配置可以采取configFile选项,这是没有记录的anywhere。
我可以看到,我可以从karma source code传递一个karma source code选项
var config = cfg.parseConfig(cliOptions.configFile, cliOptions);
是否有提及configFile选项的业力API文档,咕哝业力如何知道给use it。
发布于 2014-07-22 14:02:10
这个问题令人惊讶地相关,并且这些评论中的大多数都轻松地忽略了在这篇文章末尾提出的实际问题:“咕噜-业力如何知道如何使用配置对象和一个名为configFile的属性。
我也一直在想同样的事情,因为在业力配置文档中任何地方都没有列出该属性。例如,如果我想通过我的吞咽文件中的公共API运行我的业力测试。会是这样的:.
var karmaConfig = require('spec/karma.conf.js');
// where my config file exports an object with properties like exclude:, path:
karma.start(karmaConfig)}, process.exit);这很好,除非我想导出配置函数,这样我就可以使用配置常量(概述了here):
// allows me to do this
module.exports = function(config) {
config.set({
logLevel: config.LOG_INFO
});
}但是,除非你使用这样的东西,否则就没有办法让它发挥作用:
karma.start({configFile: 'spec/karma.conf.js'}, process.exit);在这里,我只是传递一个带有属性configFile的对象,该属性指向实际的配置文件。
Karma 没有在任何地方提到(在本评论中),但这是在使用配置函数导出方法时通过API运行我的测试的唯一方法。
https://stackoverflow.com/questions/24871069
复制相似问题