From b6954608a97c349c99205f25f9f677447a9a0b7a Mon Sep 17 00:00:00 2001 From: Nathan Hunzaker Date: Tue, 11 Aug 2015 14:47:55 -0400 Subject: [PATCH] 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` --- lib/config.js | 4 ++++ test/unit/config.spec.js | 10 ++++++++++ 2 files changed, 14 insertions(+) diff --git a/lib/config.js b/lib/config.js index 6b3c8a028..885aa8751 100644 --- a/lib/config.js +++ b/lib/config.js @@ -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] diff --git a/test/unit/config.spec.js b/test/unit/config.spec.js index 835675603..ef2740552 100644 --- a/test/unit/config.spec.js +++ b/test/unit/config.spec.js @@ -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', () => {