Skip to content

Commit 632dd5e

Browse files
committed
fix(config): Default remaining client options if any are set
Closes #961
1 parent 482654c commit 632dd5e

2 files changed

Lines changed: 23 additions & 1 deletion

File tree

lib/config.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,12 @@ var normalizeConfig = function(config, configFilePath) {
138138
throw new Error('Invalid configuration: client.args must be an array of strings');
139139
}
140140

141+
var defaultClient = config.defaultClient || {};
142+
Object.keys(defaultClient).forEach(function(key) {
143+
var option = config.client[key];
144+
config.client[key] = helper.isDefined(option) ? option : defaultClient[key];
145+
});
146+
141147
// normalize preprocessors
142148
var preprocessors = config.preprocessors || {};
143149
var normalizedPreprocessors = config.preprocessors = Object.create(null);
@@ -225,7 +231,7 @@ var Config = function() {
225231
this.loggers = [constant.CONSOLE_APPENDER];
226232
this.transports = ['websocket', 'flashsocket', 'xhr-polling', 'jsonp-polling'];
227233
this.plugins = ['karma-*'];
228-
this.client = {
234+
this.defaultClient = this.client = {
229235
args: [],
230236
useIframe: true,
231237
captureConsole: true

test/unit/config.spec.coffee

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ describe 'config', ->
207207
expect(config.basePath).to.equal resolveWinPath('./some')
208208
expect(config.urlRoot).to.equal '/' # default value
209209

210+
it 'should default unset options in client config', ->
211+
config = e.parseConfig null, {client: {args: ['--test']}}
212+
213+
expect(config.client.useIframe).to.not.be.undefined
214+
expect(config.client.captureConsole).to.not.be.undefined
215+
216+
config = e.parseConfig null, {client: {useIframe: true}}
217+
218+
expect(config.client.args).to.not.be.undefined
219+
expect(config.client.captureConsole).to.not.be.undefined
220+
221+
config = e.parseConfig null, {client: {captureConsole: true}}
222+
223+
expect(config.client.useIframe).to.not.be.undefined
224+
expect(config.client.args).to.not.be.undefined
225+
210226

211227
describe 'normalizeConfig', ->
212228

0 commit comments

Comments
 (0)