diff --git a/lib/config.js b/lib/config.js index c353c1938..02cd8ec36 100644 --- a/lib/config.js +++ b/lib/config.js @@ -138,6 +138,12 @@ var normalizeConfig = function(config, configFilePath) { throw new Error('Invalid configuration: client.args must be an array of strings'); } + var defaultClient = config.defaultClient || {}; + Object.keys(defaultClient).forEach(function(key) { + var option = config.client[key]; + config.client[key] = helper.isDefined(option) ? option : defaultClient[key]; + }); + // normalize preprocessors var preprocessors = config.preprocessors || {}; var normalizedPreprocessors = config.preprocessors = Object.create(null); @@ -225,7 +231,7 @@ var Config = function() { this.loggers = [constant.CONSOLE_APPENDER]; this.transports = ['websocket', 'flashsocket', 'xhr-polling', 'jsonp-polling']; this.plugins = ['karma-*']; - this.client = { + this.defaultClient = this.client = { args: [], useIframe: true, captureConsole: true diff --git a/test/unit/config.spec.coffee b/test/unit/config.spec.coffee index ca67a2e04..182561293 100644 --- a/test/unit/config.spec.coffee +++ b/test/unit/config.spec.coffee @@ -207,6 +207,22 @@ describe 'config', -> expect(config.basePath).to.equal resolveWinPath('./some') expect(config.urlRoot).to.equal '/' # default value + it 'should default unset options in client config', -> + config = e.parseConfig null, {client: {args: ['--test']}} + + expect(config.client.useIframe).to.not.be.undefined + expect(config.client.captureConsole).to.not.be.undefined + + config = e.parseConfig null, {client: {useIframe: true}} + + expect(config.client.args).to.not.be.undefined + expect(config.client.captureConsole).to.not.be.undefined + + config = e.parseConfig null, {client: {captureConsole: true}} + + expect(config.client.useIframe).to.not.be.undefined + expect(config.client.args).to.not.be.undefined + describe 'normalizeConfig', ->