|

Day 65 of 100: playwright.config.ts — Every Option That Matters

Day 65 of 100 — 100 Days of Playwright with TypeScript Challenge. Phase: Playwright. JavaScript (Days 1-33) → TypeScript (Days 34-63) → Playwright (Days 64-96) → AI Framework Capstone (Days 97-100).

🎭 Want to master this with real projects? Join the Playwright Automation Mastery course at The Testing Academy.


The config file controls everything: browsers, retries, parallelism, artifacts. Decode it line by line.

Contents

The Annotated Config

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

export default defineConfig({
  testDir: './tests',
  fullyParallel: true,                  // files AND tests in parallel
  forbidOnly: !!process.env.CI,         // test.only fails CI (Day 56!)
  retries: process.env.CI ? 2 : 0,      // retry flakes in CI only
  workers: process.env.CI ? 2 : undefined,
  reporter: [['html'], ['list']],
  timeout: 30_000,                      // per test
  expect: { timeout: 5_000 },           // per assertion

  use: {                                 // shared test options
    baseURL: process.env.BASE_URL ?? 'http://localhost:3000',
    trace: 'on-first-retry',
    screenshot: 'only-on-failure',
    video: 'retain-on-failure',
  },

  projects: [
    { name: 'chromium', use: { ...devices['Desktop Chrome'] } },
    { name: 'firefox', use: { ...devices['Desktop Firefox'] } },
    { name: 'mobile', use: { ...devices['Pixel 7'] } },
  ],
});

🚀 Level Up Your Playwright

From locators to CI pipelines — build a production-grade Playwright + TypeScript framework step by step.

TS Patterns You Recognize

  • process.env.CI ? 2 : 0 — ternary config (Day 4), typed env (Day 51)
  • ?? for baseURL default — nullish coalescing (Day 32)
  • …devices[‘Desktop Chrome’] — typed spread (Day 14)
  • The whole object validates against PlaywrightTestConfig — satisfies-style safety (Day 59)

Sane Defaults to Steal

  • trace on-first-retry: free debugging artifacts only when needed
  • retries CI-only: local failures stay loud
  • baseURL set: tests use page.goto(‘/path’) — environment-portable

Tomorrow (Day 66): Locators part 1 — getByRole and the accessibility-first model.

🎓 Master Playwright End to End

Join hundreds of SDETs building real automation frameworks. Lifetime access, hands-on projects, and a job-ready portfolio.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.