Testing

Last updated Oct 18, 2026 The Workers platform provides complementary tools for testing different parts of your application. For most projects, use the Workers Vitest integration for unit tests and the createTestHarness() API for integration tests.

Miniflare is not a hardened sandbox

Do not use Miniflare to run untrusted or potentially malicious Worker code directly on your machine. Run the entire development process inside an appropriate secure sandbox, such as a virtual machine.

Miniflare starts a local workerd ↗︎ process. This warning applies to default local execution with wrangler dev, vite dev, vite preview, direct Miniflare use, and Miniflare-based testing tools. Setting remote: true on a binding changes which resource your code accesses, but your Worker code still executes locally. By contrast, legacy wrangler dev --remote executes your Worker code on Cloudflare.

Miniflare is not a security boundary for untrusted code. Although workerd attempts to restrict Worker code to configured resources, an implementation bug could allow code to escape those restrictions. The hosted Workers platform applies additional layers of defense in depth that Miniflare does not provide locally.

Unit tests

Use the Workers Vitest integration for fast feedback while testing individual functions and modules. Tests run inside the Workers runtime, so your test code can access bindings and runtime APIs directly.

The Workers Vitest integration provides:

  • Fast feedback while testing individual functions and modules.
  • Direct assertions against binding state, such as values written to KV, R2, D1, or Durable Objects.
  • Direct calls to Durable Objects and other runtime APIs.

To set up unit tests, refer to Write your first Vitest test.

Integration tests

Use the createTestHarness() API to exercise one or more Workers as a whole and test how they interact with each other and with external services.

The integration test harness provides:

  • Confidence from exercising production Worker builds.
  • Coverage through configured HTTP routes across Workers.
  • Compatibility with any Node.js test runner and tools such as Playwright or MSW.

To set up integration tests, refer to Get started with the integration test harness.

Was this helpful?

YesNo

On this page

Testing - 图1Docs

{"@context":"https://schema.org","@type":"WebPage","@id":"https://developers.cloudflare.com/workers/testing/#page","headline":"Testing","description":"Choose testing tools for Cloudflare Workers, including createTestHarness and the Vitest integration.","url":"https://developers.cloudflare.com/workers/testing/","inLanguage":"en","image":"https://developers.cloudflare.com/workers/testing/og.png?v=15a28c7def4c6221","dateModified":"2026-10-18","publisher":{"@type":"Organization","name":"Cloudflare","description":"One platform for your apps, agents, and workforce. Build, secure, and scale without managing infrastructure","url":"https://www.cloudflare.com/","sameAs":["https://github.com/cloudflare","https://www.linkedin.com/company/cloudflare","https://x.com/cloudflare"],"logo":{"@type":"ImageObject","url":"https://developers.cloudflare.com/logo.svg"},"address":{"@type":"PostalAddress","streetAddress":"101 Townsend St","addressLocality":"San Francisco","addressRegion":"CA","postalCode":"94107","addressCountry":"US"},"contactPoint":[{"@type":"ContactPoint","contactType":"Customer Support","url":"https://support.cloudflare.com/","availableLanguage":["English"]},{"@type":"ContactPoint","contactType":"Sales","url":"https://www.cloudflare.com/contact/","availableLanguage":["English"]}]},"isPartOf":{"@type":"WebSite","@id":"https://developers.cloudflare.com/#website","name":"Cloudflare Docs","url":"https://developers.cloudflare.com/"}}


description: Simulate and test Cloudflare Workers locally with Miniflare, a fully-local development simulator. title: Miniflare image: https://developers.cloudflare.com/workers/testing/miniflare/og.png?v=0e9fdd4cd87b0c90


Skip to content

Documentation Index
Fetch the complete documentation index at: https://developers.cloudflare.com/workers/llms.txt
Use this file to discover all available pages before exploring further.