Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] Specific test retries #10825

Closed
awnclaim opened this issue Dec 9, 2021 · 9 comments
Closed

[Question] Specific test retries #10825

awnclaim opened this issue Dec 9, 2021 · 9 comments
Assignees
Labels
feature-test-runner Playwright test specific issues

Comments

@awnclaim
Copy link

awnclaim commented Dec 9, 2021

Hi!

Is there any way I could set the maximum number of retries to a specific test function?

My case is the following: in my test, I create an object via a POST request and then I want to verify that the response body of a GET request contains some info about it. The matter is that our backend will return no info within 2-4 minutes after the object is created, so I need to send one request after another, retrying this test, to ultimately reach the point when the response contains the info I need. At the same time, I don't want my other tests / test files to be retried X times as well. If they fail, they fail.

Is it possible to make such an adjustment to one test only? Thank you very much!

@dgozman
Copy link
Contributor

dgozman commented Dec 9, 2021

@awnclaim There is no such feature as of today. As a workaround, you can put this test into a separate file and use a separate project for it:

// playwright.config.ts

const config = {
  projects: [
    {
       name: 'default',
       testIgnore: ['retried-test.spec.ts'],
    },
    {
       name: 'retried',
       testMatch: /retried-test.spec.ts/,
       retries: 2,
    },
  ],
};

@awnclaim
Copy link
Author

awnclaim commented Dec 9, 2021

Hello,

Thanks for your reply. I would like to express my strong desire to include this in your backlog, as in the workaround you suggested all test functions will be retried in case our backend does not respond, and this is not something we would want.

Could I please ask another question? To apply this workaround, I would need to create separate authentication setups for the suits not to impede each other (i. e., make several suits log in under different credentials). Right now, as I understand, only one globalSetup is possible. What would you suggest to implement to start all test suits with one command, so that they could be run in parallel with several workers but under different login & email?

@dgozman
Copy link
Contributor

dgozman commented Dec 9, 2021

I would like to express my strong desire to include this in your backlog

Of course 👍

Right now, as I understand, only one globalSetup is possible. What would you suggest to implement to start all test suits with one command, so that they could be run in parallel with several workers but under different login & email?

Yeah, that's not an easy problem, but we are working on a nice ergonomic solution for this. For now, you'll have to log in twice in the single globalSetup and save multiple storage states, as described here.

@awnclaim
Copy link
Author

awnclaim commented Dec 9, 2021

Hello,

Thank you so much for drawing my attention to this instruction, I hadn't noticed it before.

I'll stay tuned to the updates from you guys!

@awnclaim awnclaim closed this as completed Dec 9, 2021
@dgozman
Copy link
Contributor

dgozman commented Dec 9, 2021

Let's keep this issue open to track the "set retries per single test" feature request.

@johno-stripe
Copy link

Great to see a label saying this is en route! My overall setup depends on related test cases being in the same file, but only one of them should ever need a retry. It'd be super helpful to be able to specify that test's retry count with the same syntax I use for its custom timeout.

@aslushnikov
Copy link
Collaborator

With 1.28 you can do

test.describe.configure({
  retries: 3,
});

@OliverJAsh
Copy link

Let's keep this issue open to track the "set retries per single test" feature request.

As far as I can tell, this is still not possible. You can set retries per describe but not per test. Should we re-open this issue?

@alexkuc
Copy link

alexkuc commented Dec 11, 2023

@OliverJAsh

There is support for anonymous describe so you could do something like this to override retries for individual test:

test.describe(() => {
	test.describe.configure({ retries: 2 });
	test('title', async () => {
		...
	});
});

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature-test-runner Playwright test specific issues
Projects
None yet
Development

No branches or pull requests

7 participants