aceternity-ui
100+ animated React components (Aceternity UI) for Next.js with Tailwind. Use for hero sections, parallax, 3D effects, or…
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.
Claude Code
$ npx -y skills add secondsky/claude-skills --skill cloudflare-workers-testing --agent claude-code
Codex
$ npx skills add secondsky/claude-skills --skill cloudflare-workers-testing -a codex -y
Cursor
$ npx skills add secondsky/claude-skills --skill cloudflare-workers-testing -a cursor -y
Gemini CLI
$ npx skills add secondsky/claude-skills --skill cloudflare-workers-testing -a gemini-cli -y
GitHub Copilot
$ npx skills add secondsky/claude-skills --skill cloudflare-workers-testing -a github-copilot -y
OpenCode
$ npx skills add secondsky/claude-skills --skill cloudflare-workers-testing -a opencode -y
Windsurf
$ npx skills add secondsky/claude-skills --skill cloudflare-workers-testing -a windsurf -y
name: cloudflare-workers-testing description: 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. license: MIT metadata: keywords: "cloudflare-workers, workers-testing, vitest, vitest-workers, miniflare, cloudflare-test, unit-testing, integration-testing, binding-mocks, d1-testing, kv-testing, r2-testing, durable-objects-testing, queue-testing, workers-ai-testing, test-coverage, test-failures, mock-errors, @cloudflare/vitest-pool-workers, cloudflare:test, env-mocking, execution-context, workers-test-setup, vitest-config, test-driven-development, tdd-workers" version: "1.0.0" last_verified: "2025-01-27" production_tested: true token_savings: "~70%" errors_prevented: 8 templates_included: 3 references_included: 5 scripts_included: 2 vitest_version: "^2.0.0" workers_types_version: "4.20260408.0" vitest_pool_workers_version: "0.7.2"
**Status**: ✅ Production Ready | Last Verified: 2025-01-27 **Vitest**: ^2.0.0 | **@cloudflare/vitest-pool-workers**: 0.7.2 | **Miniflare**: Latest
---
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.
---
**@cloudflare/vitest-pool-workers 0.7.2** (January 2025):
**Migration from older versions**:
# Update dependencies
bun add -D vitest@^2.1.8 @cloudflare/vitest-pool-workers@^0.7.2
# Update vitest.config.ts (new pool configuration format)
export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.jsonc' },
miniflare: { compatibilityDate: '2025-01-27' }
}
}
}
});---
bun add -D vitest @cloudflare/vitest-pool-workers
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.jsonc' },
miniflare: {
compatibilityDate: '2025-01-27',
compatibilityFlags: ['nodejs_compat']
}
}
}
}
});import { describe, it, expect } from 'vitest';
import { env, createExecutionContext, waitOnExecutionContext } from 'cloudflare:test';
import worker from '../src/index';
describe('Worker', () => {
it('responds with 200', async () => {
const request = new Request('http://example.com/');
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
await waitOnExecutionContext(ctx);
expect(response.status).toBe(200);
});
});bun test # or bunx vitest
---
**✅ CORRECT**:
import { env } from 'cloudflare:test';
it('queries D1', async () => {
const result = await env.DB.prepare('SELECT * FROM users').all();
expect(result.results).toHaveLength(0); // Fresh isolated DB per test
});**❌ WRONG**:
// Don't manually create env object
const env = { DB: mockDB }; // ❌ Won't use real D1 binding**Why**: `cloudflare:test` provides real bindings configured from `wrangler.jsonc` with isolated storage per test.
**✅ CORRECT**:
it('handles async operations', async () => {
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
await waitOnExecutionContext(ctx); // ✅ Ensures ctx.waitUntil completes
expect(response.status).toBe(200);
});**❌ WRONG**:
it('missing wait', async () => {
const ctx = createExecutionContext();
const response = await worker.fetch(request, env, ctx);
// ❌ Missing waitOnExecutionContext - ctx.waitUntil tasks may not complete
expect(response.status).toBe(200);
});**Why**: Workers use `ctx.waitUntil()` for background tasks (logging, analytics). Without waiting, these tasks may not complete in tests.
**✅ CORRECT**:
describe('KV Operations', () => {
it('test 1: writes to KV', async () => {
await env.CACHE.put('key', 'value1');
const val = await env.CACHE.get('key');
expect(val).toBe('value1'); // ✅ Isolated
});
it('test 2: clean state', async () => {
const val = await env.CACHE.get('key');
expect(val).toBeNull(); // ✅ Test 1's data doesn't leak here
});
});**Why**: Each test runs with fresh binding storage (automatic isolation).
**✅ CORRECT**:
// vitest.config.ts exp
145 production-ready skills for Claude Code CLI 🔌 Platform / Harness Support These plugins ship as Claude Code marketplace plugins (.claude-plugin/ manifests) and Codex CLI plugins (.codex-plugin/ manifests).
100+ animated React components (Aceternity UI) for Next.js with Tailwind. Use for hero sections, parallax, 3D effects, or…
Secure API authentication with JWT, OAuth 2.0, API keys. Use for authentication systems, third-party integrations,…
Creates comprehensive API changelogs documenting breaking changes, deprecations, and migration strategies for API consumers. Use…
Verifies API contracts between services using consumer-driven contracts, schema validation, and tools like Pact. Use when testing…
Master REST and GraphQL API design principles to build intuitive, scalable, and maintainable APIs that delight developers. Use…
Implements standardized API error responses with proper status codes, logging, and user-friendly messages. Use when building…
You MUST use this before any creative work - creating features, building components, adding functionality, modifying behavior, or…
Ask which skill or flow fits your situation. A router over the skills in this repo.