Testing
The Workers platform has a variety of ways to test your applications, depending on your requirements. We recommend using the Vitest integration, which allows for unit testing individual functions within workerd ↗. However, if you don't use Vitest, both Miniflare's API and the unstable_startWorker() API provide options for testing your Worker in any testing framework.
Write your first test
| Feature | Vitest integration | unstable_startWorker() | Miniflare's API |
|---|---|---|---|
| Unit testing | ✅ | ❌ | ❌ |
| Integration testing | ✅ | ✅ | ✅ |
| Loading Wrangler configuration files | ✅ | ✅ | ❌ |
| Use bindings directly in tests | ✅ | ❌ | ✅ |
| Isolated per-test storage | ✅ | ❌ | ❌ |
| Outbound request mocking | ✅ | ❌ | ✅ |
| Multiple Worker support | ✅ | ✅ | ✅ |
| Direct access to Durable Objects | ✅ | ❌ | ❌ |
| Run Durable Object alarms immediately | ✅ | ❌ | ❌ |
| List Durable Objects | ✅ | ❌ | ❌ |
| Testing service Workers | ❌ | ✅ | ✅ |