Rayrun
← Back to Discord Forum

Retry global setup and beforeAll hook

I am trying to fetch a bearer token in global setup and using the same I am making a post call in beforeAll hook. Sometimes request call/call to fetch token fails. Is there any way we can retry global setup as well as beforeAll hook

This thread is trying to answer question "Is there any way we can retry global setup as well as beforeAll hook when fetching a bearer token fails?"

2 replies
sashaknits
sashaknits

You could use expect.toPass in your global setup so it retries the attempt to get the token: https://playwright.dev/docs/test-assertions#expecttopass

Or you could make your global setup a project dependency, then it should be retried according to your retry config: https://playwright.dev/docs/test-global-setup-teardown#project-dependencies

deadbeef01

Great answer thanks

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 luc@ray.run.