Skip to content

Commit

Permalink
fix(cucumberjs): fix cucumberMulti parser for not reading all feature…
Browse files Browse the repository at this point in the history
…s, fix for correctly removing --specs
  • Loading branch information
Wim Selles committed Sep 14, 2016
1 parent 519d968 commit 877eae4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 5 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(','))
}

Expand Down
4 changes: 2 additions & 2 deletions src/parsers/cucumber.multi.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions test/unit/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'])
})
})
})
Expand Down

0 comments on commit 877eae4

Please sign in to comment.