You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
How to Retry a complete Failed Scenario in CodeceptJS with Playwright and BDD (Gherkin)? #5003
I'm using CodeceptJS with the Playwright helper and BDD-style Gherkin syntax for writing tests. I want to retry an entire scenario if it fails, rather than retrying individual steps.
For example, if a scenario fails due to a temporary glitch (e.g., network issue or slow response), I want the whole scenario to automatically re-run a specified number of times before being marked as failed.
I've found options like retryFailedStep in CodeceptJS config, but that seems to apply only to individual steps.
Is there a built-in way or a recommended approach to retry failed scenarios in CodeceptJS when using Gherkin?
I'd appreciate any examples or configuration snippets if available.
However, since I'm using BDD-style tests with Gherkin syntax, I can't use Scenario().retry() directly — it's only available in code-based scenarios, not in .feature files. I have hundreds of Gherkin scenarios, so manually converting them to programmatic definitions just to add retries isn't practical.
Is there a way to apply retries globally or configure retries for Gherkin scenarios, possibly through hooks or the configuration file?
thanks for the reply @myrepojuly
I think the code below doesn't work in BDD/Gherkin-style tests:
Before((test)=>{
// you can use test.tags to filter the feature/scenarios
Activity
apatelia commentedon Jul 11, 2025
Did you try
Scenario().retry()?https://codecept.io/basics/#retry-scenario
Ntripur commentedon Jul 21, 2025
However, since I'm using BDD-style tests with Gherkin syntax, I can't use Scenario().retry() directly — it's only available in code-based scenarios, not in .feature files. I have hundreds of Gherkin scenarios, so manually converting them to programmatic definitions just to add retries isn't practical.
Is there a way to apply retries globally or configure retries for Gherkin scenarios, possibly through hooks or the configuration file?
myrepojuly commentedon Jul 21, 2025
Hi @Nikitha22735 @Ntripur
Just use this
like wise at the suite level as well.
Additionally, to set re-tries in the config, refer retry
Ntripur commentedon Jul 21, 2025
thanks for the reply @myrepojuly
I think the code below doesn't work in BDD/Gherkin-style tests:
Before((test)=>{
// you can use test.tags to filter the feature/scenarios
test.retries(1)
})
myrepojuly commentedon Jul 21, 2025
@Ntripur I am using BDD/Gherkin and it works with both the above methods.
Not sure how you are using the hooks and the configs…
myrepojuly commentedon Aug 23, 2025
Kindly share a reproducible code to review.
github-actions commentedon Nov 22, 2025
This issue is stale because it has been open for 90 days with no activity.