Skip to main content

API Reference Overview

Playwright Test provides a comprehensive API for writing and running end-to-end tests. This reference covers the core APIs, fixtures, and configuration options available.

Core Test API

The test API is the foundation of Playwright Test. It provides functions for defining tests, organizing them into suites, and managing test execution.

Main Functions

Test Modifiers

Advanced Features

Fixtures

Playwright Test uses fixtures to establish the test environment. Fixtures are automatically set up and torn down for each test.

Built-in Fixtures

  • Test Fixtures - Fixtures available to each test (page, context, request, agent)
  • Worker Fixtures - Fixtures shared across tests (browser, playwright)

Fixture Types

Configuration

Playwright Test is configured through a configuration file that defines how tests are run, which browsers to use, and various other options.

Configuration Options

Key Configuration Areas

  • Test execution - workers, timeout, retries, fullyParallel
  • Browser options - browserName, headless, channel, launchOptions
  • Context options - viewport, baseURL, storageState, permissions
  • Recording options - screenshot, video, trace
  • Reporting - reporter, reportSlowTests

Common Patterns

Basic Test

Test with Custom Fixtures

Grouped Tests

Type Definitions

Playwright Test is written in TypeScript and provides complete type definitions. Import types from @playwright/test:

Next Steps