Contributing: Cloudflare Workers
This guide explains how to run Workers-focused tests locally.
Prerequisites
- Node.js 20+
- Wrangler CLI
- Docker (for local PostgreSQL/MySQL/Redis)
Local Setup
bash
npm installMiniflare Harness
Miniflare is used for Workers integration tests.
bash
npm run test:workersPostgreSQL (optional)
Set the environment variables to enable integration tests:
WORKERS_PG_HOSTWORKERS_PG_PORTWORKERS_PG_DATABASEWORKERS_PG_USERWORKERS_PG_PASSWORD
Example:
bash
export WORKERS_PG_HOST=127.0.0.1
export WORKERS_PG_PORT=5432
export WORKERS_PG_DATABASE=postgres
export WORKERS_PG_USER=postgres
export WORKERS_PG_PASSWORD=postgres
npm run test:workers