Skip to content

Commit

Permalink
fix(config): Error when browers option isn't array
Browse files Browse the repository at this point in the history
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`
  • Loading branch information
nhunzaker committed Aug 16, 2015
1 parent 378c9e3 commit b695460
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,10 @@ var normalizeConfig = function (config, configFilePath) {
throw new Error('Invalid configuration: client.args must be an array of strings')
}

if (config.browsers && Array.isArray(config.browsers) === false) {
throw new TypeError('Invalid configuration: browsers option must be an array')
}

var defaultClient = config.defaultClient || {}
Object.keys(defaultClient).forEach(function (key) {
var option = config.client[key]
Expand Down
10 changes: 10 additions & 0 deletions test/unit/config.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ describe('config', () => {
expect(config.preprocessors).not.to.have.property(resolveWinPath('*.coffee'))
expect(config.preprocessors).to.have.property(resolveWinPath('/**/*.html'))
})

it('should validate that the browser option is an array', () => {
var invalid = function () {
normalizeConfigWithDefaults({
browsers: 'Firefox'
})
}

expect(invalid).to.throw('Invalid configuration: browsers option must be an array')
})
})

describe('createPatternObject', () => {
Expand Down

0 comments on commit b695460

Please sign in to comment.