Use @cloudflare/test-server to write integration tests for your Workers in any Node.js test runner. It runs each project's Build Output, which cf build writes, so your tests exercise what you deploy.
@cloudflare/test-server is experimental, and its API may change in minor versions.
Get started
View complete example
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
- Runs your project's production build
- 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
Configure the test server
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 server with MSW and Playwright.
Migrate from createTestHarness()
Move tests from Wrangler's createTestHarness() to createTestServer().