Cloudflare has announced a new Workers Vitest integration that allows developers to write unit and integration tests for Cloudflare Workers. This integration provides the ability to run tests within the same runtime as Cloudflare Workers in production, allowing for greater confidence in the behavior of Workers when deployed. The integration also includes features like hot-module-reloading, watch mode, and per-test isolated storage. Developers can get started with testing Workers via Vitest by using the create-cloudflare tool or by manually installing and setting up the Workers Vitest integration.

13m read timeFrom blog.cloudflare.com
Post cover image
Table of contents
Get started testing Workers with VitestTest anything exported from a WorkerBetter testing experience === better testingHow Vitest traditionally worksSolving the problem with custom poolsDynamic code evaluationDurable Objects as test runnersIntegration tests with hot-module-reloadingIsolated per-test storageDeclarative request mockingTesting Durable Objects directlyTry it out!

Sort: