Skip to main content

Integration test harness

createTestHarness() is a Wrangler API for integration testing from any Node.js test runner. It runs one or more Workers from Wrangler projects or Vite projects that use the Cloudflare Vite plugin.

Get started

View complete example

Features

  • Runs production build output from Wrangler or the Cloudflare Vite plugin
  • Dispatches requests and events to one or more Workers
  • Provides access to bindings and local storage from tests
  • Captures logs and diagnostic output from the Workers runtime

Guides

Configure the test harness

Configure Workers, test values, lifecycle hooks, and failure diagnostics.

Prepare test state

Seed storage, mock outbound requests, and replace bindings.

Interact with Workers

Test routes, dispatch events, control Workflows, and assert logs.

Integrations

Use the test harness with MSW and Playwright.