diff --git a/src/index.js b/src/index.js index 364d483..ad1b7a8 100644 --- a/src/index.js +++ b/src/index.js @@ -53,9 +53,12 @@ export default function (options = {}, callback = function noop () {}) { let protractorArgs = [protractorBinPath].concat(parsedOptions.protractorArgs) let output = '' - if (specFiles.length) { - protractorArgs = protractorArgs.filter((arg) => !/^--(suite|specs)/.test(arg)) + protractorArgs = protractorArgs.filter((arg) => !/^--suite=/.test(arg)) + let specIndex = protractorArgs.indexOf('--specs') + if (specIndex > -1) { + protractorArgs.splice(specIndex, 2) + } protractorArgs.push('--specs', specFiles.join(',')) } diff --git a/src/parsers/cucumber.multi.js b/src/parsers/cucumber.multi.js index 94cbfcb..e601d89 100644 --- a/src/parsers/cucumber.multi.js +++ b/src/parsers/cucumber.multi.js @@ -4,14 +4,14 @@ export default { let match = null let failedSpecs = [] let testsOutput = output.split('------------------------------------') - let RESULT_FAIL = /Failures:.*/g + let RESULT_FAIL = 'Failures:' let SPECFILE_REG = /Specs:\s(.*\.feature)/g testsOutput.forEach(function (test) { let specfile let result = 'passed' // only check specs when RESULT_FAIL, ` Specs: ` is always printed when at least multiple features on 1 instance // are run with `shardTestFiles: true` - if (RESULT_FAIL.exec(test)) { // eslint-disable-line no-cond-assign + if (test.indexOf(RESULT_FAIL) > -1) { // eslint-disable-line no-cond-assign while (match = SPECFILE_REG.exec(test)) { // eslint-disable-line no-cond-assign specfile = match[1] result = 'failed' diff --git a/test/unit/index.test.js b/test/unit/index.test.js index 686a3d0..503e3fa 100644 --- a/test/unit/index.test.js +++ b/test/unit/index.test.js @@ -128,7 +128,7 @@ describe('Protractor Flake', () => { it('removes --specs argument from protractorArgs if it is passed', () => { protractorFlake({ maxAttempts: 3, - protractorArgs: ['--specs=specs/fail'] + protractorArgs: ['--specs', '/specs/fail'] }) spawnStub.dataCallback(failedShardedTestOutput) @@ -140,10 +140,10 @@ describe('Protractor Flake', () => { it('does not remove --specs for first test run', () => { protractorFlake({ maxAttempts: 3, - protractorArgs: ['--specs=specs/fail'] + protractorArgs: ['--specs', '/specs/fail'] }) - expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--specs=specs/fail']) + expect(spawnStub).to.have.been.calledWith('node', [pathToProtractor(), '--specs', '/specs/fail']) }) }) })