How to Retry a complete Failed Scenario in CodeceptJS with Playwright and BDD (Gherkin)?
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.
Did you try Scenario().retry() ?
https://codecept.io/basics/#retry-scenario
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?
Hi @Nikitha22735 @Ntripur
Just use this
Before((test)=>{
// you can use test.tags to filter the feature/scenarios
test.retries(1)
})
like wise at the suite level as well.
Additionally, to set re-tries in the config, refer retry
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) })
@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…
Kindly share a reproducible code to review.
This issue is stale because it has been open for 90 days with no activity.