Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ protractorFlake({
protractorArgs: [],
// specify a different protractor config to apply after the first execution attempt
// either specify a config file, or cli args (ex. --capabilities.browser=chrome)
protractorRetryConfig: 'path/to/<protractor-retry-config>.js'
protractorRetryConfig: 'path/to/<protractor-retry-config>.js',
// if no specs are found to be failing, restart past attempt specs if true
allowRestartAllSpecs: true
}, function (status, output) {
process.exit(status);
});
Expand Down
12 changes: 8 additions & 4 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default function (options = {}, callback = function noop () {}) {
let parser = getParser(parsedOptions.parser)
let logger = new Logger(parsedOptions.color)

function handleTestEnd (status, output = '') {
function handleTestEnd (status, output = '', pastSpecs = []) {
if (status === 0) {
callback(status)
} else {
Expand All @@ -33,8 +33,12 @@ export default function (options = {}, callback = function noop () {}) {
if (parsedOptions.protractorRetryConfig) {
logger.log('info', `Using provided protractorRetryConfig: ${parsedOptions.protractorRetryConfig}\n`)
}
if (failedSpecs.length === 0) {
logger.log('info', '\nTests failed but no specs were found. All specs will be run again.\n\n')
if (failedSpecs.length === 0 && parsedOptions.allowRestartAllSpecs) {
logger.log('info', '\nTests failed but no specs were found. Specs from past attempt will be run again.\n\n')
failedSpecs = pastSpecs
} else if (failedSpecs.length === 0 && !parsedOptions.allowRestartAllSpecs) {
logger.log('info', '\nTests failed but no specs were found. Ending.')
return
} else {
logger.log('info', 'Re-running the following test files:\n')
logger.log('info', failedSpecs.join('\n') + '\n')
Expand Down Expand Up @@ -83,7 +87,7 @@ export default function (options = {}, callback = function noop () {}) {
})

protractor.on('exit', function (status) {
handleTestEnd(status, output)
handleTestEnd(status, output, specFiles)
})
}

Expand Down
4 changes: 3 additions & 1 deletion src/parse-options.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ const DEFAULT_OPTIONS = {
parser: 'standard',
// specify a different protractor config to apply after the first execution attempt
// either specify a config file, or cli args (ex. --capabilities.browser=chrome)
protractorRetryConfig: undefined
protractorRetryConfig: undefined,
// if no specs are found to be failing, restart past attempt specs if true
allowRestartAllSpecs: true
}

function parseOptions (providedOptions) {
Expand Down