feat(browser-run): add Cloudflare hosted browsers

IR
22d ago
+1243-23

Cloudflare Browser Run runs headless Chrome on Cloudflare’s network.

This PR adds @e2e-dev/browser-run to run existing e2e web tests through Playwright CDP.

import type { E2EConfig } from 'e2e';
import { web } from '@e2e-dev/web';
import { browserRun } from '@e2e-dev/browser-run';

export default {
  targets: [{
    name: 'cloudflare',
    engine: web({ browser: browserRun({ liveView: true }) }),
    app: { url: 'https://staging.example.com' },
  }],
  workers: 2,
} satisfies E2EConfig;
export CLOUDFLARE_ACCOUNT_ID="<account-id>"
export CLOUDFLARE_API_TOKEN="<token-with-Browser-Rendering-Edit>"

The app URL must be reachable from Cloudflare.

flowchart LR
  E[e2e runner] --> P[browserRun provider]
  P -->|create / delete sessions| C[Cloudflare Browser Run]
  E <-->|authenticated CDP| C
  C --> A[Your app]
  C -.->|read-only test-tab link| V[Live View]
ConfigurationBrowser lifetimeIsolation
browserRun()One per workerFresh context per attempt
browserRun({ scope: 'attempt' })One per attempt and retryFresh browser
  • Cancellable HTTP 429 retries honor Retry-After.
  • CDP authentication headers stay separate from page requests and are redacted from connection errors.
  • Screenshots, traces and engine WebM video work. Remote downloads and Cloudflare-native recording attachments are unsupported.