The test.beforeEach() hook can be used inside a test.describe() group. When it is called inside test.describe(), it runs before each test in that group.

For example:

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

test.describe('website test', () => {
  test.beforeEach(async ({ page }, testInfo) => {
    console.log(`Running ${testInfo.title}`);
    await page.goto('https://www.designcise.com');
  });

  test('one', async ({ page }) => {
    // ...
  });

  test('two', async ({ page }) => {
    // ...
  });
});

In this example, test.beforeEach() will be called once for each of the two tests.

Please note that if multiple test.beforeEach() hooks are added, they will run in the order of their registration.