npx skills add ...
npx skills add cloudflare/workerd --skill wd-test-format
Detailed guide for authoring .wd-test files in workerd, with examples of bindings, Durable Objects, multi-service configs, TypeScript tests, and network access.
npx skills add cloudflare/workerd --skill wd-test-format
.wd-test File Format.wd-test files are Cap'n Proto configs that define test workers for workerd's test framework. They use the schema defined in src/workerd/server/workerd.capnp.
This skill is split across multiple files for context efficiency. The core patterns below cover standard single-service tests. Advanced configuration patterns live in a reference file.
You MUST read the reference file before writing or reviewing test configs that involve its subject matter. Do not guess at advanced config syntax — the reference file contains the exact patterns and fields required. Skipping it WILL lead to incorrect configs that fail at runtime.
| File | MUST load when... |
|---|---|
reference/advanced-configs.md | Test involves Durable Objects, multiple services |
| communicating via service bindings, outbound network access, | |
| external services/sockets, or TypeScript source files |
When in doubt about whether the reference file is relevant, load it — the cost of reading is far less than the cost of a broken test config.
Key rules:
unitTests) must match what the test runner expectsmodules uses embed to inline file contents at build time"worker" — this is the entry pointcompatibilityFlags control which APIs are available. Use the compat-date-at tool to look up available flags and their enable dates.compatibilityDate should not be used in wd-test; use specific flags insteadBindings make services, data, and namespaces available to the worker via env:
Test files export named objects with a test() method:
Additional data entries for fixture files:
Every wd_test() automatically generates three variants:
| Target suffix | Compat date | Description |
|---|---|---|
@ | 2000-01-01 | Default, tests with oldest compat date |
@all-compat-flags | 2999-12-31 | Tests with all flags enabled |
@all-autogates | 2000-01-01 | Tests with all autogates enabled |
Run specific variants:
Use just new-test to scaffold a new test:
This creates the .wd-test file, .js test file, and appends the wd_test() rule to BUILD.bazel.