agentleFS
CloudflareKnown publishercloudflare/workers-sdk/packages/vitest-plugin/AGENTS.md

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

Dec 2025: 0 mentionsJan 2026: 0 mentionsFeb 2026: 0 mentionsMar 2026: 0 mentionsApr 2026: 0 mentionsMay 2026: 1 mentionJun 2026: 0 mentionsJul 2026: 0 mentionsAug 2026: 1 mentionSep 2026: 0 mentionsOct 2026: 0 mentionsNov 2026: 0 mentions
Dec 2025Jun 2026Nov 2026
Mentions a month of the cloudflare/workers-sdk repository that our weekly crawl found. There is no adoption data for this file yet.

Who's talking about cloudflare/workers-sdk

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

9 more on GitHub

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
  1. Very specific:

    NOT exported via package.json — internal entry

    line 25
  2. Very specific:

    Does NOT extend vitest.shared.ts

    line 73
  3. Very specific:

    Test helper: custom test fixture with tmpPath, seed(), vitestRun(), vitestDev()

    line 76

≈ “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.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
AGENTS.md

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.ts provides the cloudflareTest() Vite plugin, which injects cloudflare:test resolution 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, via wrangler.unstable_readConfig()
  • experimental: { newConfig } — a cloudflare.config.ts, via src/pool/new-config.ts (@cloudflare/config's loadAndParseConfig() → convertToWranglerConfig() → normalizeAndValidateConfig()). Mirrors @cloudflare/vite-plugin's experimental.newConfig. ctx.mode comes from project.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):

  1. pool — src/pool/index.ts → dist/pool (emits type declarations)
  2. worker + libs — src/worker/index.ts plus src/worker/lib and src/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

  • expect must come from test context: it("name", ({ expect }) => {}) — never import { expect } from "vitest"
  • Tests use .test.ts naming
  • Excludes *.worker.test.ts from 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 test fixture with tmpPath, 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

Download now (ZIP)

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
What did you use it for? e.g. Reviewing pull requests in a Rails app

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.