Skip to content
This repository was archived by the owner on Sep 11, 2025. It is now read-only.
This repository was archived by the owner on Sep 11, 2025. It is now read-only.

Document globalSetup usage #611

@adamyonk

Description

@adamyonk

In the documentation there is reference to setting up authentication in globalSetup and then sharing that login across all test runs:

  1. Run tests (for example, with npm run test).
  2. Login via UI and retrieve authentication state.
    • In Jest, this can be executed in globalSetup.
  3. In each test, load authentication state in beforeEach or beforeAll step.

This seems to suggest a setup like:

// jest.config.js
module.exports = {
  globalSetup: '<rootDir>/jest.globalSetup.js',
  preset: 'jest-playwright-preset',
  setupFilesAfterEnv: ['expect-playwright', '<rootDir>/jest.setup.js'],
}

But there is nothing playwright-related setup when globalSetup runs:

// jest.globalSetup.js
module.exports = async function globalSetup() {
  console.log('setting up', Object.keys(global));
};

So does going this route require manually setting up playwright, or is there some way to get access to the instance that jest-playwright-preset creates?

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions