E2e testing

From Automattic/woocommerce-payments · View interactive version

E2e testing is an AI agent skill from the GitHub repository Automattic/woocommerce-payments. Run or debug WooPayments Playwright E2E tests and set up its local E2E environment. Use when an E2E check is requested or needed for the affected flow, not for every code change.

How to use this skill

Skill file

WooPayments E2E Testing

Run Playwright E2E tests to verify changes work from a user's perspective — real browser, real Stripe test transactions, real WordPress site.

When to Use

Choose a focused spec or scenario, and inspect the current environment before setup or rebuilding. Broaden checks only when a failure, new change or specific unresolved risk warrants it. A request to test does not authorise resetting data or stopping unrelated containers. Use test-mode payment data.

Quick Reference

| Task | Command |

|------|---------|

| First-time setup | bin/setup-e2e-local.sh && pnpm run build:client && pnpm run test:e2e-setup |

| Run all tests | pnpm run test:e2e |

| Run specific test | pnpm run test:e2e tests/e2e/specs/wcpay/merchant/file.spec.ts |

| Run by name | pnpm run test:e2e -g "test name" |

| Run merchant tests | pnpm run test:e2e tests/e2e/specs/wcpay/merchant |

| Run shopper tests | pnpm run test:e2e tests/e2e/specs/wcpay/shopper |

| UI mode | pnpm run test:e2e-ui (open http://localhost:8077) |

| Start containers | pnpm run test:e2e-up |

| Stop containers | pnpm run test:e2e-down |

| Full reset | pnpm run test:e2e-reset |

| View report | pnpm exec playwright show-report |

Workflow 1: First-Time Setup

Prerequisites

Steps

  1. Run the setup script:

```bash

bin/setup-e2e-local.sh

```

This auto-detects credentials from:

It asks interactively for anything it can't find.

Options:

  1. Build the client:

```bash

pnpm run build:client

```

  1. Set up the E2E Docker environment:

```bash

pnpm run test:e2e-setup

```

This takes several minutes. It:

  1. Verify it works:

```bash

pnpm run test:e2e tests/e2e/specs/wcpay/merchant/merchant-admin-deposits.spec.ts

```

Important: Pre-setup steps for local server mode

Before running pnpm run test:e2e-setup, these steps are required:

  1. Sync gitignored server code: The transact-platform-server has server/ and missioncontrol/ gitignored (populated via pnpm run pull). After the E2E setup clones the repo, these dirs are empty. The setup script (bin/setup-e2e-local.sh) handles this automatically, or manually:

```bash

rsync -a --delete /path/to/transact-platform-server/server/ tests/e2e/deps/transact-platform-server-e2e/server/

rsync -a --delete /path/to/transact-platform-server/missioncontrol/ tests/e2e/deps/transact-platform-server-e2e/missioncontrol/

```

  1. Install dev tools dependencies: The dev tools plugin needs composer install after cloning:

```bash

cd tests/e2e/deps/wcp-dev-tools-e2e && composer install --no-dev --no-interaction

```

  1. Pre-clone dev tools (optional): To avoid the clone + install race condition, pre-clone before running setup:

```bash

git clone --depth=1 "$WCP_DEV_TOOLS_REPO" tests/e2e/deps/wcp-dev-tools-e2e

cd tests/e2e/deps/wcp-dev-tools-e2e && composer install --no-dev

```

Troubleshooting Setup

```yaml

services:

playwright:

environment:

```

Workflow 2: Running Tests (Agent Verification)

Before running tests

  1. Check Docker with docker info and inspect running services with docker ps. Start the existing E2E environment with pnpm run test:e2e-up when needed; use first-time setup only if it has not been configured.
  2. Confirm the checkout and client assets match the revision being tested. Run pnpm run build:client only if assets are missing or stale. Reuse a current build.
  3. Inspect the relevant specs and their prerequisites. Select the smallest scenario that observes the changed behavior, including relevant failure paths.

Choosing what to run

Run a focused spec, optionally narrowed to a test name:

pnpm run test:e2e tests/e2e/specs/wcpay/merchant/merchant-admin-disputes.spec.ts
pnpm run test:e2e tests/e2e/specs/wcpay/merchant/merchant-admin-disputes.spec.ts -g "test name"

Use the feature mapping below to locate candidates, then inspect the current filenames and test names. Run a merchant/shopper directory, tag group or full suite only when explicitly requested or when the affected shared behavior needs that breadth. State the gap the broader run will cover.

Stop when the relevant checks pass. If setup or an integration blocks a check, report the blocker and what remains unverified; do not substitute an unrelated passing suite. Clean up only agent-owned processes and temporary test state.

Reading results

Test mapping — which specs cover which features

| Feature area | Spec directory / files |

|-------------|----------------------|

| Deposits/payouts | merchant/merchant-admin-deposits.spec.ts |

| Transactions | merchant/merchant-admin-transactions.spec.ts |

| Disputes | merchant/merchant-admin-disputes.spec.ts, merchant-disputes-*.spec.ts |

| Orders & refunds | merchant/merchant-orders-*.spec.ts |

| Multi-currency | merchant/multi-currency*.spec.ts, merchant/merchant-orders-multi-currency.spec.ts |

| Payment settings | merchant/merchant-payment-settings-*.spec.ts |

| Checkout (shortcode) | shopper/shopper-checkout-*.spec.ts |

| Checkout (blocks) | shopper/ specs tagged @blocks |

| Saved cards | shopper/shopper-saved-card*.spec.ts |

| WooPay | merchant/woopay-setup.spec.ts, shopper/shopper-woopay*.spec.ts |

| Subscriptions | specs/subscriptions/ |

Workflow 3: Debugging Failures

Step 1: Read the failure output

The console shows which test failed and the error message. Look for:

Step 2: Check artifacts

# Screenshots (taken on failure)
ls tests/e2e/test-results/

# Open the HTML report
pnpm exec playwright show-report

# Open a specific trace
pnpm exec playwright show-trace tests/e2e/test-results/<test-folder>/trace.zip

Step 3: Access the E2E site directly

The E2E WordPress site stays running after tests:

Step 4: Check container logs

# WordPress container logs
docker logs wcp_e2e_wordpress --tail 50

# Server container logs (local server mode)
docker logs transact_platform_server_wordpress_e2e --tail 50

# MySQL logs
docker logs wcp_e2e_mysql --tail 50

Step 5: Run in UI mode for interactive debugging

pnpm run test:e2e-ui tests/e2e/specs/wcpay/merchant/failing-test.spec.ts

Open http://localhost:8077 in your browser. UI mode lets you:

Writing New E2E Tests

Directory structure

| Test type | Directory |

|-----------|----------|

| Merchant tests | tests/e2e/specs/wcpay/merchant/ |

| Shopper tests | tests/e2e/specs/wcpay/shopper/ |

| Subscription merchant | tests/e2e/specs/subscriptions/merchant/ |

| Subscription shopper | tests/e2e/specs/subscriptions/shopper/ |

Test patterns

import { test, expect } from '@playwright/test';
import { getMerchant, getShopper } from '../../utils/helpers';

test.describe( 'Feature description', () => {
    test( 'should do something specific', async ( { browser } ) => {
        const { merchantPage } = await getMerchant( browser );
        // ... test steps
    } );
} );

Key conventions

Test cards

Defined in tests/e2e/config/default.ts:

Environment Reference

| Service | URL | Container |

|---------|-----|-----------|

| E2E WordPress | http://localhost:8084 | wcp_e2e_wordpress |

| E2E MySQL | localhost:5698 | wcp_e2e_mysql |

| E2E phpMyAdmin | http://localhost:8085 | wcp_e2e_phpmyadmin |

| Transact Server | http://localhost:8088 | transact_platform_server_wordpress_e2e |

| Playwright UI | http://localhost:8077 | (via docker-compose) |

Lifecycle Commands

Cleanup and reset remove dependencies or volumes. Inspect ownership and obtain explicit authorisation for data deletion before using them. Stop only services owned by the current task or covered by existing authorisation.

pnpm run test:e2e-setup    # First-time: build + start + configure everything
pnpm run test:e2e-up       # Start existing containers (no reconfigure)
pnpm run test:e2e-down     # Stop containers
pnpm run test:e2e-cleanup  # Remove deps and docker volumes
pnpm run test:e2e-reset    # Stop + cleanup (full teardown)
Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.