Skip to content

Commit

Permalink
Merge pull request #88 from rasjani/issue-11
Browse files Browse the repository at this point in the history
Passes flake.params.iteration to protractor
  • Loading branch information
NickTomlin committed Mar 15, 2018
2 parents 874a08e + 5b448c7 commit dfaef0d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/index.js
Expand Up @@ -47,6 +47,7 @@ export default function (options = {}, callback = function noop () {}) {
let output = ''
let protractorArgs = [parsedOptions.protractorPath].concat(parsedOptions.protractorArgs)

protractorArgs.push('--params.flake.iteration', testAttempt)
if (retry) {
protractorArgs.push('--params.flake.retry', true)
}
Expand All @@ -55,7 +56,6 @@ export default function (options = {}, callback = function noop () {}) {
protractorArgs = filterArgs(protractorArgs)
protractorArgs.push('--specs', specFiles.join(','))
}

let protractor = spawn(
parsedOptions.nodeBin,
protractorArgs,
Expand Down
25 changes: 13 additions & 12 deletions test/unit/index.test.js
Expand Up @@ -43,7 +43,7 @@ describe('Protractor Flake', () => {
it('uses node to run protractor', () => {
protractorFlake()

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor()])
expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.iteration', 1])
})

context('failed specs', () => {
Expand Down Expand Up @@ -91,8 +91,7 @@ describe('Protractor Flake', () => {

spawnStub.dataCallback(failedSingleTestOutput)
spawnStub.endCallback(1)

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.retry', true, '--specs', '/tests/a-flakey.test.js'])
expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.iteration', 2, '--params.flake.retry', true, '--specs', '/tests/a-flakey.test.js'])
})

it('isolates individual failed specs from jasmine-spec-reporter output', () => {
Expand All @@ -101,7 +100,7 @@ describe('Protractor Flake', () => {
spawnStub.dataCallback(failedJasmineSpecReporterTestOutput)
spawnStub.endCallback(1)

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.retry', true, '--specs', '/tests/flakey.test.js'])
expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.iteration', 2, '--params.flake.retry', true, '--specs', '/tests/flakey.test.js'])
})

it('isolates individual failed specs for sharded jasmine-spec-reporter output', () => {
Expand All @@ -110,7 +109,7 @@ describe('Protractor Flake', () => {
spawnStub.dataCallback(failedShardedJasmineSpecReporterTestOutput)
spawnStub.endCallback(1)

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.retry', true, '--specs', '/tests/flakey.test.js'])
expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.iteration', 2, '--params.flake.retry', true, '--specs', '/tests/flakey.test.js'])
})

it('isolates failed specs for sharded protractor output', () => {
Expand All @@ -119,7 +118,7 @@ describe('Protractor Flake', () => {
spawnStub.dataCallback(failedShardedTestOutput)
spawnStub.endCallback(1)

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.retry', true, '--specs', '/tests/a-flakey.test.js,/tests/another-flakey.test.js'])
expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--params.flake.iteration', 2, '--params.flake.retry', true, '--specs', '/tests/a-flakey.test.js,/tests/another-flakey.test.js'])
})

context('with --suite in protractorArgs', function () {
Expand All @@ -139,6 +138,7 @@ describe('Protractor Flake', () => {
expect(spawnStub).to.have.been.calledWith('node', [
pathToProtractor(),
'--should-remain=yes',
'--params.flake.iteration', 2,
'--params.flake.retry', true,
'--specs', '/tests/a-flakey.test.js,/tests/another-flakey.test.js'
])
Expand All @@ -150,7 +150,7 @@ describe('Protractor Flake', () => {
protractorArgs: ['--suite=fail']
})

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--suite=fail'])
expect(spawnStub).to.have.been.calledWith('node', [ pathToProtractor(), '--suite=fail', '--params.flake.iteration', 1 ])
})
})

Expand All @@ -171,6 +171,7 @@ describe('Protractor Flake', () => {
expect(spawnStub).to.have.been.calledWith('node', [
pathToProtractor(),
'--should-remain=yes',
'--params.flake.iteration', 2,
'--params.flake.retry', true,
'--specs', '/tests/a-flakey.test.js,/tests/another-flakey.test.js'
])
Expand All @@ -182,7 +183,7 @@ describe('Protractor Flake', () => {
protractorArgs: ['--specs=specs/fail', '--specs', 'specs/fail']
})

expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--specs=specs/fail', '--specs', 'specs/fail'])
expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--specs=specs/fail', '--specs', 'specs/fail', '--params.flake.iteration', 1])
})
})
})
Expand All @@ -191,25 +192,25 @@ describe('Protractor Flake', () => {
it('allows a different path for protractor by using protractorPath option', () => {
protractorFlake({protractorPath: '/arbitrary/path/to/protractor'})

expect(spawnStub).to.have.been.calledWith('node', ['/arbitrary/path/to/protractor'])
expect(spawnStub).to.have.been.calledWith('node', ['/arbitrary/path/to/protractor', '--params.flake.iteration', 1])
})

it('allows a different path for node by using nodeBin option', () => {
protractorFlake({nodeBin: '/path/node'})

expect(spawnStub).to.have.been.calledWith('/path/node', [pathToProtractor()])
expect(spawnStub).to.have.been.calledWith('/path/node', [pathToProtractor(), '--params.flake.iteration', 1])
})

it('passes protractorArgs to spawned protractor process', () => {
protractorFlake({protractorArgs: ['--suite=fail']})

expect(spawnStub).to.have.been.calledWithMatch('node', [pathToProtractor(), '--suite=fail'])
expect(spawnStub).to.have.been.calledWithMatch('node', [pathToProtractor(), '--suite=fail', '--params.flake.iteration', 1])
})

it('uses protractorSpawnOptions for spawned protractor process', () => {
protractorFlake({protractorSpawnOptions: { cwd: './' }})

expect(spawnStub).to.have.been.calledWithMatch('node', [pathToProtractor()], { cwd: './' })
expect(spawnStub).to.have.been.calledWithMatch('node', [pathToProtractor(), '--params.flake.iteration', 1], { cwd: './' })
})

context('color option', (options) => {
Expand Down

0 comments on commit dfaef0d

Please sign in to comment.