Afsal
Afsal

Reputation: 504

Playwright: Run multiple tests in a spec using 1 worker at a time

My Playwright scripts are configured to run in parallel (default) on Chrome, FF and Safari.

import { devices, PlaywrightTestConfig } from '@playwright/test';
const config: PlaywrightTestConfig = {
  ...
  workers: 3,
  fullyParallel: false,
  },
  projects: [
    {
      name: 'Chrome',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'Firefox',
      use: { ...devices['Desktop Firefox'] },
    },
    {
      name: 'Safari',
      use: { ...devices['Desktop Safari'] },
    },
  ],

One of my spec files has the below code

  test.describe('Home Tests', () => {
    let page: Page; 
    let homeView: HomeView;

  test.beforeEach(async ({ page }) => {
      homeView = new HomeView(page);
  });

  test('01', async () => {
    await dashboard.login(false, ownerEmail);
    ...
  });

  test('02', async () => {
    await dashboard.login(false, ownerEmail);
    ...
  });
.
.
.

When I run this test, test 01 is taken up by all 3 browsers and executed in parallel. Due to technical login restrictions of the app, only one test passes and the rest fails. I want test 1 to run in Chrome first and once it is completed it should run on FF second and Safari next (which browser first doesn't matter)

I do not want to change the settings globally or make this possible on the CLI level. I want to handle this at the same spec file level. How can I achieve this?

Upvotes: 2

Views: 2333

Answers (1)

Anton Ivanov
Anton Ivanov

Reputation: 19

try to use "test.describe.serial"

Upvotes: -1

Related Questions