Cloudflare

Improved Cloudflare Workers testing via Vitest and workerd

Mar 15, 2024Brendan Coll, Adam Murray
Improved Cloudflare Workers testing via Vitest and workerd
SummaryAI, from the source post

This post introduces a new Vitest integration for Cloudflare Workers, allowing developers to write unit and integration tests that execute directly within the `workerd` runtime. This enables testing of Worker code, interactions with Cloudflare products (KV, R2, D1, Queues, Service Bindings), and Cron Triggers. The integration uses Vitest's custom pools feature to run the test runner within `workerd`, communicating via WebSockets. It also provides features like hot-module-reloading and per-test isolated storage.

More from the Edge Computing with Cloudflare Workers trail