secondsky avatar

Cloudflare Workers Testing

This is a complete testing setup for Cloudflare Workers using Vitest 2.1.8 and the official @cloudflare/vitest-pool-workers 0.7.2. It covers the full workflow: configuring the test pool, accessing real bindings through cloudflare:test (D1, KV, R2, Durable Objects, Queues, AI), handling execution contexts properly with waitOnExecutionContext, and setting up isolated storage per test. The critical rules section is worth your time because it shows the exact mistakes people make, like forgetting to wait on context or trying to mock env manually instead of using the provided module. Updated for the January 2025 breaking changes in Miniflare v3, so you won't be chasing outdated syntax.

skills.sh installs
340
GitHub stars
248
last updated
Aug 21, 2026

Install

$ npx -y skills add secondsky/claude-skills --skill cloudflare-workers-testing --agent claude-code

Installs into .claude/skills of the current project.

Files

Cloudflare Workers Testing with Vitest

Status: ✅ Production Ready | Last Verified: 2025-01-27 Vitest: ^2.0.0 | @cloudflare/vitest-pool-workers: 0.7.2 | Miniflare: Latest

Table of Contents


What Is Workers Testing?

Testing Cloudflare Workers with Vitest and @cloudflare/vitest-pool-workers enables writing unit and integration tests that run in a real Workers environment with full binding support (D1, KV, R2, Durable Objects, Queues, AI). Tests execute in Miniflare for local development and can run in CI/CD with actual Workers runtime behavior.

Key capabilities: Binding mocks, execution context testing, edge runtime simulation, coverage tracking, fast test execution.


New in 2025

Sponsors

Details

Repository
github.com/secondsky/claude-skills
Categories
Testing & QA, Documentation, Cloud & Infrastructure
First seen
Jun 3, 2026

More from secondsky/claude-skills

All 146
1supabase avatarstudio-testingsupabase/supabaseTesting strategy for Supabase Studio. Use when writing tests, deciding whether a change needs tests and which type, extracting logic from components into testab337skills.sh installs
2thedivergentai avatargodot-testing-patternsthedivergentai/gd-agentic-skillsExpert testing decision trees for GdUnit4: unit vs scene vs CI gates, headless runners, snapshots, and mock networks. Use when choosing test layers, wiring CI, 329skills.sh installs
3patricio0312rev avatarapi-test-suite-generatorpatricio0312rev/skillsGenerates comprehensive API test suites using Jest, Vitest, or Supertest from Express, Next.js, Fastify, or other API routes. Creates integration tests, contrac314skills.sh installs
4davila7 avatartesting-patternsdavila7/claude-code-templatesJest testing patterns, factory functions, mocking strategies, and TDD workflow. Use when writing unit tests, creating test factories, or following TDD red-green306skills.sh installs
5pproenca avatarrails-testingpproenca/dot-skillsRuby on Rails testing best practices for writing effective, maintainable test suites with RSpec. This skill should be used when writing, reviewing, or refactori301skills.sh installs
6patricio0312rev avatarapi-mock-serverpatricio0312rev/skillsCreates mock API servers for testing and development with MSW, json-server, or custom handlers. Use when users request "API mocking", "mock server", "MSW setup"297skills.sh installs