Skip to content

Commit b695460

Browse files
committed
fix(config): Error when browers option isn't array
I forgot that the `browsers` option must be an array. This commit catches this case and throws a more descriptive error instead of something a long the lines of `TypeError: undefined is not a function`
1 parent 378c9e3 commit b695460

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/config.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,10 @@ var normalizeConfig = function (config, configFilePath) {
149149
throw new Error('Invalid configuration: client.args must be an array of strings')
150150
}
151151

152+
if (config.browsers && Array.isArray(config.browsers) === false) {
153+
throw new TypeError('Invalid configuration: browsers option must be an array')
154+
}
155+
152156
var defaultClient = config.defaultClient || {}
153157
Object.keys(defaultClient).forEach(function (key) {
154158
var option = config.client[key]

test/unit/config.spec.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,16 @@ describe('config', () => {
300300
expect(config.preprocessors).not.to.have.property(resolveWinPath('*.coffee'))
301301
expect(config.preprocessors).to.have.property(resolveWinPath('/**/*.html'))
302302
})
303+
304+
it('should validate that the browser option is an array', () => {
305+
var invalid = function () {
306+
normalizeConfigWithDefaults({
307+
browsers: 'Firefox'
308+
})
309+
}
310+
311+
expect(invalid).to.throw('Invalid configuration: browsers option must be an array')
312+
})
303313
})
304314

305315
describe('createPatternObject', () => {

0 commit comments

Comments
 (0)