Skip to content

Commit e9f4836

Browse files
committed
Fix retryFailedStep ignoredSteps exact-name matching
The wildcard check used `ignored.indexOf('*')` as a boolean. `-1` is truthy in JavaScript (only `0` is falsy), so entries without `*` were matched via `startsWith(slice(0, -1))` instead of exact compare, which also chops the last character — broadening the match further. `ignoredSteps: ['see']` silently ignored `seeElement`, `seeInField`, `selectOption`, `sendPostRequest` — anything starting with `se`. Compare against `-1` explicitly so exact-name entries only match themselves, as the docs describe.
1 parent f0c7563 commit e9f4836

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

lib/plugin/retryFailedStep.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ export default function (config) {
116116
if (step.title === ignored) return
117117
if (ignored instanceof RegExp) {
118118
if (step.title.match(ignored)) return
119-
} else if (ignored.indexOf('*') && step.title.startsWith(ignored.slice(0, -1))) return
119+
} else if (ignored.indexOf('*') !== -1 && step.title.startsWith(ignored.slice(0, -1))) return
120120
}
121121
enableRetry = true
122122
})

test/unit/plugin/retryFailedStep_test.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,36 @@ describe('retryFailedStep', () => {
157157
// expects to retry only once
158158
})
159159

160+
it('should not treat exact-name ignoredSteps entries as wildcard prefixes', async () => {
161+
// Regression: ignored.indexOf('*') was used as truthy check.
162+
// -1 is truthy, so entries without '*' were matched via startsWith(slice(0, -1)).
163+
// ignoredSteps: ['see'] would silently ignore seeElement, seeInField, selectOption, etc.
164+
retryFailedStep({ retries: 2, minTimeout: 1, ignoredSteps: ['see'] })
165+
event.dispatcher.emit(event.test.before, createTest('test'))
166+
167+
let counter = 0
168+
event.dispatcher.emit(event.step.started, { title: 'seeElement' })
169+
try {
170+
await recorder.add(
171+
() => {
172+
counter++
173+
if (counter < 3) {
174+
throw new Error()
175+
}
176+
},
177+
undefined,
178+
undefined,
179+
true,
180+
)
181+
await recorder.promise()
182+
} catch (e) {
183+
await recorder.catchWithoutStop(err => err)
184+
}
185+
186+
// seeElement is NOT in ignoredSteps (only 'see' is) — should be retried.
187+
expect(counter).to.be.greaterThan(1)
188+
})
189+
160190
it('should add custom regexp steps to ignore', async () => {
161191
retryFailedStep({ retries: 2, minTimeout: 1, ignoredSteps: [/somethingNew/] })
162192
event.dispatcher.emit(event.test.before, createTest('test'))

0 commit comments

Comments
 (0)