End-to-end testing with Playwright for WooGraphQL Next storefronts
The Playwright plugin sets up Playwright for end-to-end browser testing. It activates automatically when the e2e/ template directory is included in your project.
Dev dependencies:
@playwright/test - Playwright test runnerfluent-ffmpeg - Video processing for test recordingsffmpeg-static - Static ffmpeg binary for video conversionglob - File pattern matching for test utilitiesThe plugin runs npx playwright install --with-deps to download browser binaries (Chromium) before your project dependencies are installed.
export default defineConfig({ testDir: './e2e', globalTeardown: './e2e/utils/convert-videos.mjs', fullyParallel: true, forbidOnly: !!process.env.CI, retries: process.env.CI ? 2 : 0, workers: process.env.CI ? 1 : 4, timeout: 60000, reporter: [['html'], ['list']], use: { baseURL: process.env.FRONTEND_URL || 'http://localhost:3000', trace: 'on-first-retry', screenshot: 'only-on-failure', video: 'on', }, projects: [ { name: 'chromium', use: { ...devices['Desktop Chrome'] }, }, ], webServer: [ { command: 'npm run start', url: 'http://localhost:3000', timeout: 60000, reuseExistingServer: !process.env.CI, }, ], });
Key settings:
FRONTEND_URL env var, defaults to http://localhost:3000.only callsThe e2e/ directory includes these test files:
| File | Description |
|---|---|
smoke.spec.ts | Health checks: homepage loads, content renders, navigation links exist |
shop.spec.ts | Shop page: product listings, filters, pagination, category navigation |
product.spec.ts | Product page: details, gallery, add-to-cart |
auth-flow.spec.ts | Login, registration, and session management |
Conditional test suites (based on configuration):
| File | Condition |
|---|---|
cart-flow/cart-flow.spec.ts | Cart enabled |
checkout-flow/checkout-flow.spec.ts | Checkout enabled |
cart-flow/cart-flow.spec.ts (NextPress variant) | Cart + NextPress |
checkout-flow/checkout-flow.spec.ts (NextPress variant) | Checkout + NextPress |
Build and test against a production server:
npm run build npx playwright test
Run a specific test file:
npx playwright test e2e/smoke.spec.ts
Run in headed mode to see the browser:
npx playwright test --headed
View the HTML test report:
npx playwright show-report
| Variable | Description | Default |
|---|---|---|
FRONTEND_URL | Base URL for the running app | http://localhost:3000 |
CI | Enables CI-specific settings (retries, single worker) | - |
All tests record video by default. After the test run, the globalTeardown script (e2e/utils/convert-videos.mjs) converts raw WebM recordings to MP4 using ffmpeg for easier sharing and playback.