Skip to content
Merged
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: 2 additions & 2 deletions lib/plugin/retryFailedStep.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ const RETRY_PRIORITIES = {
*
*/
export default function (config) {
config = Object.assign(defaultConfig, config)
config = Object.assign({}, defaultConfig, config)
config.ignoredSteps = config.ignoredSteps.concat(config.defaultIgnoredSteps)
const customWhen = config.when

Expand All @@ -116,7 +116,7 @@ export default function (config) {
if (step.title === ignored) return
if (ignored instanceof RegExp) {
if (step.title.match(ignored)) return
} else if (ignored.indexOf('*') && step.title.startsWith(ignored.slice(0, -1))) return
} else if (ignored.indexOf('*') !== -1 && step.title.startsWith(ignored.slice(0, -1))) return
}
enableRetry = true
})
Expand Down
17 changes: 17 additions & 0 deletions test/unit/plugin/retryFailedStep_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,23 @@ describe('retryFailedStep', () => {
// expects to retry only once
})

it('should not treat exact-name ignoredSteps entries as wildcard prefixes', () => {
// Regression: ignored.indexOf('*') was used as truthy check.
// -1 is truthy, so entries without '*' were matched via startsWith(slice(0, -1)).
// ignoredSteps: ['see'] would silently ignore seeElement, seeInField, selectOption, etc.
retryFailedStep({ retries: 2, minTimeout: 1, ignoredSteps: ['see'] })
store.autoRetries = true
const retryConfig = recorder.retries[recorder.retries.length - 1]

event.dispatcher.emit(event.step.started, { title: 'seeElement' })
expect(retryConfig.when(new Error()), "'seeElement' must not be ignored when only 'see' is configured").to.equal(true)

event.dispatcher.emit(event.step.passed, {})

event.dispatcher.emit(event.step.started, { title: 'see' })
expect(retryConfig.when(new Error()), "exact match 'see' must still be ignored").to.not.equal(true)
})

it('should add custom regexp steps to ignore', async () => {
retryFailedStep({ retries: 2, minTimeout: 1, ignoredSteps: [/somethingNew/] })
event.dispatcher.emit(event.test.before, createTest('test'))
Expand Down