From 53de30bdb6fa96b88ecb7065ef62f7e3ff434d7e Mon Sep 17 00:00:00 2001 From: Mike Eason Date: Mon, 22 Oct 2018 13:57:57 +0100 Subject: [PATCH 1/2] Always send output to flake callback This change ensures that the protractor flake callback will always receive the output log even if the first test pass succeeds with no failures. --- src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/index.ts b/src/index.ts index 4e26870..d9b4512 100644 --- a/src/index.ts +++ b/src/index.ts @@ -24,7 +24,7 @@ function flake (options: object | undefined = {}, callback: Function | undefined function handleTestEnd (status: number, output = '') { if (status === 0) { - callback(status) + callback(status, output) } else { if (++testAttempt <= parsedOptions.maxAttempts) { logger.log('info', `\nUsing ${parser.name} to parse output\n`) From e20ec77a9702e01abab90e4ae01e22689db3b0ac Mon Sep 17 00:00:00 2001 From: Michael Eason Date: Tue, 18 Dec 2018 11:01:34 +0000 Subject: [PATCH 2/2] Add unit test for status 0 flake callback --- test/unit/index.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/test/unit/index.test.ts b/test/unit/index.test.ts index 8832b59..f91efd9 100644 --- a/test/unit/index.test.ts +++ b/test/unit/index.test.ts @@ -80,6 +80,17 @@ describe('Protractor Flake', () => { spawnStub.endCallback(1) }) + it('calls callback with output from protractor process if the status is 0', (done) => { + protractorFlake({maxAttempts: 1}, (status: number, output: string) => { + expect(status).to.equal(status, 0) + expect(output).to.equal('Test') + done() + }) + + spawnStub.dataCallback('Test') + spawnStub.endCallback(0) + }) + it('does not blow up if no callback is passed', function () { protractorFlake({maxAttempts: 1})