Skip to content

Playwright Configuration

The definePlaywrightDrupalConfig() function returns a complete Playwright configuration with sensible defaults for Drupal testing. It wraps Playwright's defineConfig() and applies the following defaults:

This configuration helper, the Drupal test fixture, database lifecycle, and DDEV behavior remain exclusive to @lullabot/playwright-drupal. The generic @lullabot/playwright-testing package provides utilities rather than a replacement Playwright configuration.

The shared Drupal test fixture also enables webkitAutofocusWorkaround by default for browserName === 'webkit', including desktop Safari and mobile projects. It installs the helper from @lullabot/playwright-testing and suppresses queued native document autofocus to prevent wrong-field fill() calls. See configuration, opt-out and limitations.

Setting Default
use.baseURL process.env.DDEV_PRIMARY_URL
fullyParallel true
workers Math.max(2, os.cpus().length - 2), or PLAYWRIGHT_WORKERS when set
reporter CI: [['line'], ['html'], ['json', ...]]; Local: [['html', ...], ['list'], ['json', ...]]
globalSetup Auto-resolved path to this package's global-setup module

Overriding Defaults

PLAYWRIGHT_WORKERS overrides workers for a single invocation, taking precedence over anything passed here — see Running Tests Concurrently. Everything else is set by the overrides argument.

Plain-object properties are deep-merged with their defaults at every nesting level. For example, providing use.ignoreHTTPSErrors keeps the default use.baseURL while adding your setting. Non-object properties (including arrays like reporter) replace the default entirely.

If you need full control, you can always use Playwright's defineConfig() directly with the globalSetup path from this package.

This example imports the default configuration and shows overriding some common settings.

import { definePlaywrightDrupalConfig } from '@lullabot/playwright-drupal/config';
import { devices } from '@playwright/test';

export default definePlaywrightDrupalConfig({
  testDir: './tests',
  forbidOnly: !!process.env.CI,
  retries: process.env.CI ? 2 : 0,
  use: {
    ignoreHTTPSErrors: true,
    trace: 'on-first-retry',
  },
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
  ],
});