Setting the file. One moment.
Subchapter 6.2
references/testing.mdMarkdown2 KBView on GitHub
Use Cloudflare’s Vitest integration to exercise Durable Objects in the Workers runtime. Before changing an existing suite, inspect its installed Vitest/Cloudflare packages, configuration, and test scripts. Follow the matching API or migration guide; adding a test does not by itself require migrating the suite.
Fetch the relevant current documentation before writing setup or test code:
| Task | Documentation |
|---|---|
| Install compatible packages, configure Vitest and Wrangler, generate test types, run tests | Write your first test (opens in a new tab) |
| Migrate an existing pool-based suite | Migrate to Vitest plugin (opens in a new tab) |
| Configure bindings, runtime options, or multiple Workers | Vitest configuration (opens in a new tab) |
| Test RPC, Worker HTTP routes, instance separation, SQLite storage, and alarms | Testing Durable Objects (opens in a new tab) |
| Inspect internals, enumerate instances, or trigger scheduled alarms with test helpers | Test APIs (opens in a new tab) |
| Choose state cleanup and concurrency behavior | Isolation and concurrency (opens in a new tab) |
Choose tests around the behavior being changed:
Keep package versions, imports, configuration, helper signatures, and runnable examples in the linked documentation rather than copying them into this reference.