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`) 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})