From 9d1ac9881dcf9b06430076a125f1076652fc8dc9 Mon Sep 17 00:00:00 2001 From: Nick Tomlin Date: Fri, 5 Aug 2016 16:19:10 -0500 Subject: [PATCH] fix: Blow up if invalid parser is specified _before_ running tests --- src/index.js | 2 +- test/integration/bin.js | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/index.js b/src/index.js index 166253b..cd61301 100644 --- a/src/index.js +++ b/src/index.js @@ -15,6 +15,7 @@ const DEFAULT_OPTIONS = { export default function (options = {}, callback = function noop () {}) { let parsedOptions = Object.assign(DEFAULT_OPTIONS, options) + let parser = getParser(parsedOptions.parser) let testAttempt = 1 function handleTestEnd (status, output = '') { @@ -22,7 +23,6 @@ export default function (options = {}, callback = function noop () {}) { callback(status) } else { if (++testAttempt <= parsedOptions.maxAttempts) { - let parser = getParser(parsedOptions.parser) log('info', `Using ${parser.name} to parse output\n`) let failedSpecs = parser.parse(output) diff --git a/test/integration/bin.js b/test/integration/bin.js index 6086b7f..88fe127 100644 --- a/test/integration/bin.js +++ b/test/integration/bin.js @@ -59,4 +59,18 @@ describe('Protractor Flake Executable', function () { done() }) }) + + it('integration: exits with error if invalid parser is specified', (done) => { + let output = '' + let proc = spawnFlake(['--max-attempts', '3', '--parser', 'foo', '--', configPath('sharded')]) + proc.stderr.on('data', (buff) => { + output += buff.toString() + }) + + proc.on('close', (status) => { + expect(status).to.equal(1) + expect(output).to.contain('Error: Invalid Parser Specified: foo') + done() + }) + }) })