Skip to content

Configuration

This page is a reference for all configuration files generated by the tool and used in experiment projects.

playwright.config.js

The root Playwright configuration file. Controls test execution, browser projects, and reporting.

js
import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
  testDir: './tests',
  fullyParallel: true,
  reporter: 'html',
  use: {
    trace: 'on-first-retry',
    screenshot: 'on',
    video: 'off',
  },
  projects: [
    {
      name: 'chromium',
      use: { ...devices['Desktop Chrome'] },
    },
    {
      name: 'firefox',
      use: { ...devices['Desktop Firefox'] },
    },
    {
      name: 'webkit',
      use: { ...devices['Desktop Safari'] },
    },
  ],
});

Key Options

OptionDefaultDescription
testDir'./tests'Directory containing test files
fullyParalleltrueRun all tests in parallel
reporter'html'Output format (see Running Tests)
trace'on-first-retry'When to record traces
screenshot'on'When to capture screenshots
video'off'When to record video
projectschromium, firefox, webkitBrowsers to test against

Common Customizations

Add timeouts:

js
export default defineConfig({
  timeout: 60000,       // Per-test timeout (default: 30s)
  expect: {
    timeout: 10000,     // Per-assertion timeout (default: 5s)
  },
});

Add viewport size:

js
use: {
  viewport: { width: 1440, height: 900 },
},

Add base URL:

js
use: {
  baseURL: 'https://www.example.com',
},

Grant permissions:

js
use: {
  permissions: ['clipboard-read', 'clipboard-write'],
},

tests/config/experiment.config.js

Contains experiment-specific settings used across all test files.

js
export const experimentConfig = {
  name: 'My Experiment',
  marketGroup: 'SEBN',
  markets: [
    { code: 'BE', urlPath: 'be', name: 'Belgium (NL)' },
    { code: 'NL', urlPath: 'nl', name: 'Netherlands' },
  ],
  baseUrl: 'https://www.example.com',

  variants: {
    control: 'control',
    experiment: 'experiment',
  },

  timeouts: {
    navigation: 30000,
    element: 5000,
    api: 10000,
  },

  environment: process.env.TEST_ENV || 'qa',
  adobePreviewToken: process.env.ADOBE_PREVIEW_TOKEN || '',

  getMarketCodes() {
    return this.markets.map((m) => m.code);
  },

  getMarket(code) {
    return this.markets.find((m) => m.code === code);
  },
};

Fields

FieldTypeDescription
namestringExperiment name
marketGroupstringMarket group code (e.g., SEBN)
marketsArrayMarket objects with code, urlPath, name
baseUrlstringBase application URL
variantsObjectVariant identifiers
timeoutsObjectTimeout values in milliseconds
environmentstringTest environment (qa, staging, production)
adobePreviewTokenstringAdobe Target preview token from env var

Methods

  • getMarketCodes() - returns array of market code strings
  • getMarket(code) - finds a market object by code

Manages control and experiment URLs per market. This is the file you edit most after generation.

js
export const qaLinksConfig = {
  baseUrl: 'https://www.example.com',
  markets: [/* ... */],

  getUrls(marketCode) {
    const market = this.markets.find((m) => m.code === marketCode);
    if (!market) {
      throw new Error(`Unknown market code: ${marketCode}`);
    }
    return {
      controlUrl:
        process.env[`CONTROL_URL_${marketCode}`] ||
        `${this.baseUrl}/${market.urlPath}/control-page/`,
      experimentUrl:
        process.env[`EXPERIMENT_URL_${marketCode}`] ||
        `${this.baseUrl}/${market.urlPath}/experiment-page/`,
    };
  },

  getAllUrls() { /* returns all markets with URLs */ },
  getMarketCodes() { /* returns array of codes */ },
};

export function validateUrls() { /* warns about missing env vars */ }

URL Resolution Priority

  1. Environment variable CONTROL_URL_<CODE> / EXPERIMENT_URL_<CODE>
  2. Default pattern: ${baseUrl}/${urlPath}/control-page/ or experiment-page/

Customizing URLs

For most experiments, you replace the default URL pattern with your actual QA URLs:

js
getUrls(marketCode) {
  const market = this.markets.find((m) => m.code === marketCode);
  return {
    controlUrl: `${this.baseUrl}/${market.urlPath}/smartphones/?at_preview_token=ctrl_abc`,
    experimentUrl: `${this.baseUrl}/${market.urlPath}/smartphones/?at_preview_token=exp_xyz`,
  };
}

tests/config/index.js

Barrel export file. All config is re-exported from here so tests import from a single location:

js
export { experimentConfig } from './experiment.config.js';
export { qaLinksConfig, validateUrls } from './qa-links.config.js';

Usage in Tests

js
import { experimentConfig, qaLinksConfig, validateUrls } from '../../config/index.js';

src/js/config.js (Experiment Source Config)

This file is not generated by the tool but exists in experiment projects. It contains:

  • Selectors - CSS selectors for DOM elements the experiment targets
  • Text content - Market-specific copy and translations
  • Images - URLs for experiment assets
  • Feature flags - Toggle individual experiment features

Example structure:

js
export const config = {
  selectors: {
    targetContainer: '.product-detail__overview',
    ctaButton: '[data-cta="experiment"]',
  },
  content: {
    NL: { headline: 'Speciale Aanbieding', cta: 'Nu Kopen' },
    BE: { headline: 'Offre Speciale', cta: 'Acheter' },
  },
  features: {
    showBadge: true,
    animateEntry: false,
  },
};

Tests should reference this config rather than hardcoding expected values:

js
import { config } from '../../src/js/config.js';

test('should show correct headline', async ({ page }) => {
  await expect(page.locator('.headline')).toHaveText(config.content.NL.headline);
});

What's Next