cloudflare-workers-testing

Solid

Comprehensive testing guide for Cloudflare Workers using Vitest and @cloudflare/vitest-pool-workers. Use for test setup, binding mocks (D1/KV/R2/DO), integration tests, or encountering test failures, mock errors, coverage issues.

Testing & QA 168 stars 27 forks Updated 4 weeks ago MIT

Install

View on GitHub

Quality Score: 89/100

Stars 20%
74
Recency 20%
90
Frontmatter 20%
70
Documentation 15%
100
Issue Health 10%
50
License 10%
100
Description 5%
100

Skill Content

# Cloudflare Workers Testing with Vitest **Status**: ✅ Production Ready | Last Verified: 2025-01-27 **Vitest**: 2.1.8 | **@cloudflare/vitest-pool-workers**: 0.7.2 | **Miniflare**: Latest ## Table of Contents - [What Is Workers Testing?](#what-is-workers-testing) - [New in 2025](#new-in-2025) - [Quick Start (5 Minutes)](#quick-start-5-minutes) - [Critical Rules](#critical-rules) - [Core Concepts](#core-concepts) - [Top 5 Use Cases](#top-5-use-cases) - [Best Practices](#best-practices) - [Top 8 Errors Prevented](#top-8-errors-prevented) - [When to Load References](#when-to-load-references) --- ## 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 **@cloudflare/vitest-pool-workers 0.7.2** (January 2025): - **BREAKING**: Miniflare v3 → requires Node.js 18+ - **NEW**: `cloudflare:test` module for env/ctx access - **IMPROVED**: Faster isolated storage for bindings - **FIXED**: Worker-to-worker service bindings now work correctly - **ADDED**: Support for Vectorize and Workers AI bindings **Migration from older versio...

Details

Author
secondsky
Repository
secondsky/claude-skills
Created
7 months ago
Last Updated
4 weeks ago
Language
TypeScript
License
MIT

Integrates with

Similar Skills

Semantically similar based on skill content — not just same category