Skip to main content

beforeAll

Callable

  • beforeAll(inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, actors> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void
  • beforeAll(title: string, inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, actors> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any): void

  • Declares a beforeAll hook that is executed once per worker process before all tests.

    Details

    When called in the scope of a test file, runs before all tests in the file. When called inside a test.describe(title, callback) group, runs before all tests in the group. If multiple beforeAll hooks are added, they will run in the order of their registration.

    Note that worker process is restarted on test failures, and beforeAll hook runs again in the new worker. Learn more about workers and failures.

    You can use test.afterAll(hookFunction) to teardown any resources set up in beforeAll.

    Usage

    // example.spec.ts
    import { test, expect } from '@playwright/test';

    test.beforeAll(async () => {
    console.log('Before tests');
    });

    test.afterAll(async () => {
    console.log('After tests');
    });

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

    Parameters

    • inner: (args: PlaywrightTestArgs & PlaywrightTestOptions & Omit<SerenityOptions, actors> & SerenityFixtures & PlaywrightWorkerArgs & PlaywrightWorkerOptions & object, testInfo: TestInfo) => any

    Returns void