diff --git a/lib/plugin/retryFailedStep.js b/lib/plugin/retryFailedStep.js index cbe145910..97ff388aa 100644 --- a/lib/plugin/retryFailedStep.js +++ b/lib/plugin/retryFailedStep.js @@ -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 @@ -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 }) diff --git a/test/unit/plugin/retryFailedStep_test.js b/test/unit/plugin/retryFailedStep_test.js index 09cab5b10..33fcafa8d 100644 --- a/test/unit/plugin/retryFailedStep_test.js +++ b/test/unit/plugin/retryFailedStep_test.js @@ -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'))