1

Say, I kick off all my 87 (random number here) tests and there are 5 (basically, "some") of them that test on the same page and all of them make changes to that same page... of course, the tests all use the same userid to authenticate. Nope, I cannot have several different userids here

The tests all run in parallel using playwright workers.

Is there a way to mark these "few tests", like to place them in a queue, such as they will run alone, not in parallel with each other ? Some keyword to add to the test ? Something like "alone" or "enqueue" ?

Or any other idea ? Thanks.

AlexD
  • 561
  • 6
  • 11
  • One approach would be to move the 5 to its own directory and run it with the --workers parameter to avoid running them in parallel. For example: npx playwright test tests/my5SpecialTestCases --workers=1 – Michael S. Apr 05 '23 at 14:36
  • Are they all(87) part of single test file and even single describe block? If not, then what is the current structure? And out of those how those 5 are structured? – Vishal Aggarwal Apr 05 '23 at 15:53
  • And how they are configured to run in "Parallel"? – Vishal Aggarwal Apr 05 '23 at 15:56
  • Michael, that will be unfeasable now that the test infrastructure is in place and integrated in the CI/CD flow, but thank you. Vishal, the tests are organized by component in one directory. Then each directory/component may have several tests. We run the whole thing from the top so the execution runs whichever tests are found from the top dir. Some of the directories contain the tests that when they run, they change values in settings that will affect the interface and cause tests in the same family to fail. They run "in parallel" because of the way Playwright runs: with workers :-) Tkx – AlexD Apr 06 '23 at 18:08

1 Answers1

1

Serial Mode

You can annotate inter-dependent tests as serial. If one of the serial tests fails, all subsequent tests are skipped. All tests in a group are retried together.

Run an subset of tests in serial mode in separate file:

import { test, Page } from '@playwright/test';

// Annotate entire file as serial.
test.describe.configure({ mode: 'serial' });

let page: Page;

test.beforeAll(async ({ browser }) => {
  page = await browser.newPage();
});

test.afterAll(async () => {
  await page.close();
});

test('runs first', async () => {
  await page.goto('https://playwright.dev/');
});

test('runs second', async () => {
  await page.getByText('Get Started').click();
});
Vishal Aggarwal
  • 1,929
  • 1
  • 13
  • 23
  • 1
    Thanks Vishal. This seems something to give a nice try because it's not dependent of the test infrastructure we have in place and it's exclusively in the hands of the test engineers. I will try this today ! – AlexD Apr 06 '23 at 18:09
  • You are welcome Alex , I hope it resolved the issue. – Vishal Aggarwal Apr 07 '23 at 13:40
  • @AlexD Alex - If it resolved your issue , please accept it as the answer. – Vishal Aggarwal Apr 07 '23 at 19:04
  • I will do as soon as I can test it. I got caught in a "release week" and barely have had time to breath; but I'll test it as soon as mid coming week. – AlexD Apr 08 '23 at 14:43