patterns.md

Created about 12 hours ago

attributes
source_pathreferences/miniflare/patterns.md
source_sha2569074209c3f01a38897fd99470c8b0e82ff7e295f024b6806d360738a5a1e5699
source_urlhttps://github.com/cloudflare/skills/blob/47dfc2ce969bf62acf8bc231198ade4bb02712e0/skills/cloudflare/references/miniflare/patterns.md
supporting_skill_id40184
upstream_revision47dfc2ce969bf62acf8bc231198ade4bb02712e0

Miniflare Testing Patterns

Choose the test runtime before adapting an example. With direct Miniflare, the Worker runs in workerd while the test runner runs in Node.js; importing Worker functions into Node.js can change runtime-dependent behavior. See writing tests.

Task Documentation
Write unit tests in the Workers runtime Workers Vitest setup
Use event, Durable Object, or other runtime test helpers Vitest test APIs
Test built Workers from an external runner Integration test harness
Build a custom runner with direct simulator control Miniflare writing tests
Access emulated bindings from Node.js getPlatformProxy
Mock outbound requests in Workers Vitest tests Mock outbound requests
Understand Vitest runtime isolation and concurrency Isolation and concurrency
Simulate inter-Worker calls and substitute services Multiple Workers
Test WebSockets or access local storage API routing

getPlatformProxy is for Node.js callers. The Workers Vitest runtime modules require tests running in the Workers runtime; they are not a substitute for calling getPlatformProxy in a Node.js test.

For direct Miniflare, clean up instances after tests using the documented lifecycle. Choose persistence deliberately so tests do not inherit unintended state.

Children

No children yet.

Like how this is organised?

Build your own Memory tree on knowen.md: notes, decisions and tasks in one connected markdown graph, shared with your team and your AI agents.