Rayrun
← Back to Discord Forum

How can I retry failed test cases after all the test cases have been run?

.masoodahmedposted in #help-playwright
Open in Discord
.masoodahmed
.masoodahmed

I want to retry the failing test cases after all the test cases in the folder are run. Is it possible in playwright?

This thread is trying to answer question "How can I retry failed test cases after all the test cases have been run in Playwright?"

10 replies

Would venture a guess, could be completely wrong but it sounds like you have some tests that are dependent on other tests to run first then they will pass? Would assert all tests should be independent of each other and able to run in isolation.

.masoodahmed
.masoodahmed

No, all of my tests are independent of each other. What I am looking for is that suppose there are tests such as a,b,c,d,e. Now we run the tests and we observer b and d fails so I want those failed tests to be retried once again at the end. So sequential execution should look like a,b,c,d,e,b,d

with PW , retry runs as soon as the particular test fails.

.masoodahmed
.masoodahmed

Yes I know, but I want to retry tests at the end instead of as soon as it fails

Is this running locally or in CI build? I do not think this is possible in playwright, but if you want to rerun failures, you could add a process that at the end of each test if failure then write to a list file. Upon completion you could run a script to rerun the test files in the list file. Again, this is guess on what you want. I do not think Playwright has the functionality to retry after all tests run the failed tests. You may need to make something to do this.

If they really are independent as mentioned then the tests should work 100% all the time, Tests should only ever fail from a bug, either a product bug or a bug in the test code, either way would assert it is a bug somewhere and should be fixed.

In your playwright.config.js you can configure your retries like this:

retries: process.env.CI ? 2 : 2,

.masoodahmed
.masoodahmed

Thanks @nzcarnage for the idea. I have already implemented and found a way through custom reporter. If you guys are interested, then have a look at https://github.com/microsoft/playwright/discussions/23940

.masoodahmed
.masoodahmed

@dand33 I understand your point of view of independent tests. We were just trying a Proof Of Concept and testing how flexible playwright is compared to other softwares so that we can choose accordingly to our needs. Thanks for all your inputs. They have helped us a lot

Related Discord Threads

TwitterGitHubLinkedIn
AboutQuestionsDiscord ForumBrowser ExtensionTagsQA Jobs

Rayrun is a community for QA engineers. I am constantly looking for new ways to add value to people learning Playwright and other browser automation frameworks. If you have feedback, email [email protected].