Recipes and examples
Recipes are examples that demonstrate unit and integration tests for Workers projects using the @cloudflare/vitest-plugin package.
- Basic unit and integration tests for Workers using
exports.default - Basic unit and integration tests for Pages Functions using
exports.default - Basic integration tests using an auxiliary Worker
- Tests using KV, R2 and the Cache API
- Tests using D1 with migrations
- Tests using Durable Objects with direct access
- Tests using Workflows
- Tests using Queue producers and consumers
- Tests using Pipelines
- Tests using Hyperdrive with a Vitest managed TCP server
- Mock outbound requests with
@msw/cloudflare - Tests using multiple auxiliary Workers and request mocks
- Tests importing WebAssembly modules
- Tests using JSRPC with entrypoints and Durable Objects
- Tests using
ctx.exportsto access Worker exports - Resolve modules with Vite dependency pre-bundling
- Mock Workers AI and Vectorize bindings in unit tests
- Tests using the Images binding
- Tests mocking Workers Assets