/qa-serverless:cloudflare-workers-miniflarefrom qa-serverless
Runs Cloudflare Workers tests locally with Miniflare 3 (workerd-backed), wrangler dev, and Vitest integration. Emulates KV, Durable Objects, R2, and D1 bindings for high-fidelity local testing.
Ships in qa-serverless. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Miniflare 3 is the official Workers simulator. Per
developers.cloudflare.com/workers,
Miniflare 3 is built on top of workerd - the same runtime that
serves production Workers traffic. This means local-mode
behaviour matches prod with very high fidelity.
Three integration patterns:
wrangler dev (CLI; live-reload during dev).getMiniflare(); for integration
tests).@cloudflare/vitest-pool-workers (Vitest + in-process
Workers; the recommended unit-test path).npm install --save-dev wrangler miniflare @cloudflare/vitest-pool-workers vitest
wrangler dev --local # workerd locally; no remote calls
wrangler dev # default = local-mode in Wrangler 3+
Now curl http://localhost:8787 hits the local Worker.
Per miniflare.dev:
import { Miniflare } from 'miniflare';
const mf = new Miniflare({
scriptPath: './src/worker.js',
modules: true,
kvNamespaces: ['MY_KV'],
d1Databases: ['DB'],
r2Buckets: ['MY_BUCKET'],
durableObjects: {
COUNTER: 'Counter',
},
});
const res = await mf.dispatchFetch('https://example.com/');
expect(res.status).toBe(200);
expect(await res.text()).toBe('Hello');
await mf.dispose();
Per developers.cloudflare.com/workers/testing/vitest-integration:
// vitest.config.ts
import { defineWorkersConfig } from '@cloudflare/vitest-pool-workers/config';
export default defineWorkersConfig({
test: {
poolOptions: {
workers: {
wrangler: { configPath: './wrangler.toml' },
},
},
},
});
// src/worker.test.ts
import { env, SELF } from 'cloudflare:test';
import { expect, test } from 'vitest';
test('responds with hello', async () => {
const response = await SELF.fetch('https://example.com/');
expect(await response.text()).toBe('Hello');
});
test('writes to KV', async () => {
await env.MY_KV.put('key', 'value');
expect(await env.MY_KV.get('key')).toBe('value');
});
This is the lowest-overhead test path - runs inside workerd.
import { env } from 'cloudflare:test';
test('counter increments', async () => {
const id = env.COUNTER.idFromName('test');
const stub = env.COUNTER.get(id);
const r1 = await stub.fetch('https://example.com/increment');
expect(await r1.text()).toBe('1');
const r2 = await stub.fetch('https://example.com/increment');
expect(await r2.text()).toBe('2');
});
Per Cloudflare docs, the vitest-pool-workers env exposes the
Durable Object namespace exactly as in production.
import { env } from 'cloudflare:test';
test('d1 query', async () => {
await env.DB.exec('CREATE TABLE IF NOT EXISTS users (id INT, name TEXT)');
await env.DB.prepare('INSERT INTO users VALUES (?, ?)').bind(1, 'alice').run();
const { results } = await env.DB.prepare('SELECT * FROM users').all();
expect(results).toEqual([{ id: 1, name: 'alice' }]);
});
npx vitest run # @cloudflare/vitest-pool-workers
wrangler dev # CLI dev
jobs:
workers-tests:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npx vitest run
No CF account/API key needed - vitest-pool-workers runs
locally via workerd.
| Anti-pattern | Why it fails | Fix |
|---|---|---|
| Test against deployed Worker | Slow; flaky; rate-limited | Use vitest-pool-workers |
| Mock the fetch API | Loses Workers' standard-Web-Platform shape | Use real Worker isolation |
| Skip Durable Object tests | Fan-out + consistency bugs hide | Test DO classes directly |
KV getWithMetadata not tested for stale-read behavior | KV is eventually consistent | Test the consistency requirements |
| Local-mode time differs from prod | Cron / scheduled triggers won't fire | Test via deployed Worker + Cloudflare Cron Trigger |
| Hardcoded API key in worker | Exposed in source map / fetch | Use Workers Secrets (wrangler secret) |
| No assertion on response headers | Cache-Control / CORS bugs | Inspect response.headers |
| Cold-start tests against local Worker | Local cold start ~0ms; not representative | Per serverless-integration-test-builder (its cold-start budget reference), test cold-start budget on deployed Worker |
remote: true config in
Wrangler 3.dispatchFetch('https://example.com/__scheduled').serverless-integration-test-builder (its cold-start budget reference).aws-sam-local-testing,
azure-functions-tests.What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
4 skills in this plugin
/aws-sam-local-testingUse when AWS Lambda functions with API Gateway need testing locally: sam local invoke with event payloads, start-api for a local API Gateway, start-lambda for SDK clients and generate-event, plus .NET Lambda handler tests with Amazon.Lambda.TestUtilities./azure-functions-testsUse when Azure Functions need testing before deploy: running them locally with Core Tools v4 and Azurite, unit tests for .NET isolated, Node v4 and Python v2 handlers, HTTP, queue and timer triggers, admin-endpoint calls and binding checks in local.settings.json./serverless-integration-test-buildernpx claudepluginhub testland/qa --plugin qa-serverless2 plugins ship this exact skill · first indexed Nov 12, 2026
Other plugins' skills for the same job