workers-sdk / vitest-plugin
AGENTS.md4.6k starsChanged 6 months agoApache-2.0View on GitHub
Custom Vitest pool for running Worker tests inside the actual workerd runtime. Do NOT repeat root AGENTS.md content (pnpm, changesets, code style, etc.). - Runs in Node.js, part of the pool bundle (no separate package export) - Validates pool options (WorkersPoolOptionsSchema) and resolves the project's Worker configuration into Miniflare options - src/pool/plugin.ts provides the cloudflareTest() Vite plugin, which injects cloudflare:test resolution and sets resolve conditions (workerd, worker, browser) parseCustomPoolOptions() in src/pool/config.ts resolves at most one configuration file into a normalised…
Trending
Quiet since August.about the whole repository
Who's talking about cloudflare/workers-sdk
- cloudflare/workerd“🐛 BUG: The cache field on RequestInitializerDict is not implemented in fetch”GitHub · Apr 7, 2023 · 85 reactions
- sveltejs/kit“feat: Vite environment API”GitHub · Jul 17, 2025 · 31 reactions
- remix-run/remix“Cloudflare support for Vite”GitHub · Jan 16, 2024 · 25 reactions
- cloudflare/workerd“🐛 BUG: Workers TTFB slows down based on unused dynamic imports (additional modules)”GitHub · Mar 27, 2024 · 22 reactions
- withastro/astro“Cloudflare adapter returning [object Object]”GitHub · Oct 10, 2025 · 18 reactions
The biggest 5 of 17 mentions linking to the repository that our crawl found. Each line is their own headline.
See all 17
Talked about on GitHub, Bluesky and Hacker News (17 times).
On GitHub · 14
- Apr 7, 2023🐛 BUG: The cache field on RequestInitializerDict is not implemented in fetch — cloudflare/workerd85 reactions · 61 comments
- Jul 17, 2025feat: Vite environment API — sveltejs/kit31 reactions · 16 comments
- Jan 16, 2024Cloudflare support for Vite — remix-run/remix25 reactions · 21 comments
- Mar 27, 2024🐛 BUG: Workers TTFB slows down based on unused dynamic imports (additional modules) — cloudflare/workerd22 reactions · 6 comments
- Oct 10, 2025Cloudflare adapter returning [object Object] — withastro/astro18 reactions · 15 comments
9 more on GitHub
- May 24, 2023Support Node Compat in Cloudflare Adaptor — sveltejs/kit17 reactions · 2 comments
- Oct 17, 2024Support Wrangler, the CLI for Cloudflare Workers — denoland/deno15 reactions · 8 comments
- Aug 10, 2026feat: `@cloudflare/vite-plugin` integration, take 2 — sveltejs/kit11 reactions · 5 comments
- Jul 22, 2023Feature Request — Runtime APIs: Superfluous throws — cloudflare/workerd11 reactions
- Oct 29, 2025Add --target=cloudflare support to bundler — oven-sh/bun8 reactions · 10 comments
- Nov 6, 2025placement just got better (finally) — cloudflare/cloudflare-docs7 reactions · 6 comments
- Oct 28, 2025vitest 4.0 fails with "TypeError: filename.replace is not a function" — withastro/astro7 reactions · 3 comments
- May 23, 2025'scopes' for Secret Store's secrets not retained in local development — cloudflare/developer-platform7 reactions · 7 comments
- Jul 23, 2024bun fetch to wrangler dev server crashes server and fails with "socket connection was closed unexpectedly" — oven-sh/bun7 reactions · 20 comments
On Bluesky · 2
- Oct 20, 2023📦 cloudflare / workers-sdk ⭐ 1,781 (+48) 🗒 TypeScript ⛅️ Home to Wrangler, the CLI for Cloudflare Workers® — @github-trending-js.bsky.social1 likes and repost
- Oct 20, 2023📦 cloudflare / workers-sdk ⭐ 1,734 (+4) 🗒 TypeScript ⛅️ Home to Wrangler, the CLI for Cloudflare Workers® — @github-trending.bsky.social1 likes and repost
On Hacker News · 1
- May 2, 2026Cloudflare Workers let you deploy serverless code instantly across the globe3 points
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about checking a change actually works.
Of the AGENTS.md files we read, the 11,773 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository10 other files it gives its agents.
- AGENTS.mdAGENTS.md
- packages/auto-triage-bot/AGENTS.mdAGENTS.md
- packages/create-cloudflare/AGENTS.mdAGENTS.md
- packages/miniflare/AGENTS.mdAGENTS.md
- packages/vite-plugin-cloudflare/AGENTS.mdAGENTS.md
- packages/workers-auth/AGENTS.mdAGENTS.md
- packages/workers-utils/AGENTS.mdAGENTS.md
- packages/wrangler/AGENTS.mdAGENTS.md
- CLAUDE.mdCLAUDE.md
- local-explorerSkill
The file
We split this AGENTS.md into the rules it gives an agent
3 rules. About 0 are common, 0 are distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈0
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 25
NOT exported via package.json — internal entry
- Very specific: line 73
Does NOT extend vitest.shared.ts
- Very specific: line 76
Test helper: custom test fixture with tmpPath, seed(), vitestRun(), vitestDev()
≈ “Common” is an estimate: at least 1 in 5 of the 16,595 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
vitest-plugin — Agent Guide
Custom Vitest pool for running Worker tests inside the actual workerd runtime. Do NOT repeat root AGENTS.md content (pnpm, changesets, code style, etc.).
THREE-CONTEXT ARCHITECTURE
1. Pool (src/pool/index.ts)
- Runs in Node.js Vitest process
- Main export (
exports["."]), built as ESM (.mjs) - Orchestrates test execution
2. Config (src/pool/config.ts)
- Runs in Node.js, part of the pool bundle (no separate package export)
- Validates pool options (
WorkersPoolOptionsSchema) and resolves the project's Worker configuration into Miniflare options src/pool/plugin.tsprovides thecloudflareTest()Vite plugin, which injectscloudflare:testresolution and sets resolve conditions (workerd,worker,browser)
3. Worker (src/worker/index.ts)
- Runs inside workerd runtime
- NOT exported via package.json — internal entry
- Contains HACK: monkeypatches VitestExecutor to access singleton
- Has direct cross-package source import into
miniflare/src/workers/core/devalue
WORKER CONFIGURATION SOURCES
parseCustomPoolOptions() in src/pool/config.ts resolves at most one configuration
file into a normalised Config, then shares every downstream step (remote proxy
session, unstable_getMiniflareWorkerOptions(), main, defines, module rules, tails):
wrangler: { configPath, environment }— a Wrangler configuration file, viawrangler.unstable_readConfig()experimental: { newConfig }— acloudflare.config.ts, viasrc/pool/new-config.ts(@cloudflare/config'sloadAndParseConfig()→convertToWranglerConfig()→normalizeAndValidateConfig()). Mirrors@cloudflare/vite-plugin'sexperimental.newConfig.ctx.modecomes fromproject.vite.config.mode.
The two are mutually exclusive. Whichever is used, the resolved path, config format and
Worker name are recorded on options.resolvedConfig for the pool to consume — never
re-read the config file from disk.
BUILD
tsdown.config.ts defines 2 separate builds (all ESM):
- pool —
src/pool/index.ts→dist/pool(emits type declarations) - worker + libs —
src/worker/index.tsplussrc/worker/libandsrc/worker/node→dist/worker
Types entry types/cloudflare-test.d.ts is hand-written (NOT generated from source).
THE cloudflare:test MODULE
Tests inside workerd import from cloudflare:test:
import { env, fetchMock, SELF } from "cloudflare:test";Resolved by custom Vite plugin (@cloudflare/vitest-plugin:config) that re-exports from cloudflare:test-internal (runtime-provided).
CONVENTIONS
expectmust come from test context:it("name", ({ expect }) => {})— neverimport { expect } from "vitest"- Tests use
.test.tsnaming - Excludes
*.worker.test.tsfrom vitest config
TESTING
- Does NOT extend
vitest.shared.ts - Hook timeout: 60s, retry: 2
- Global setup starts mock npm registry, installs local package to temp dir
- Test helper: custom
testfixture withtmpPath,seed(),vitestRun(),vitestDev() - Fixtures in
fixtures/vitest-plugin-examples/(20+ sub-fixtures testing KV, R2, D1, DO, Queues,cloudflare.config.ts, etc.) - Skipped on Windows CI due to flakiness
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

