Skip to content

Migrate to Vitest plugin

@cloudflare/vitest-plugin replaces @cloudflare/vitest-pool-workers. Configuration helpers move from the /config subpath to the package root; other APIs and Vitest options are unchanged.

Run the codemod

To update your project automatically, run the following command from the project root:

npx @cloudflare/codemods vitest:pool-workers-to-vitest-plugin

Use --dry-run to preview the changes. Use --files <glob> to limit the files the codemod updates.

The codemod updates your dependency, imports, and test TypeScript configuration. It renames the package in imports but leaves /config subpaths in place. Update those helper imports manually.

Update manually

If you cannot run the codemod, update the package name in your package.json, imports, and test tsconfig.json:

- "@cloudflare/vitest-pool-workers": "^0.16.0"
+ "@cloudflare/vitest-plugin": "^1.0.0"

- import { cloudflareTest } from "@cloudflare/vitest-pool-workers";
+ import { cloudflareTest } from "@cloudflare/vitest-plugin";

- "types": ["@cloudflare/vitest-pool-workers/types"]
+ "types": ["@cloudflare/vitest-plugin/types"]

Import configuration helpers from the package root. @cloudflare/vitest-plugin does not export a /config subpath.

- import { readD1Migrations } from "@cloudflare/vitest-pool-workers/config";
+ import { readD1Migrations } from "@cloudflare/vitest-plugin";

Update request mocking

To mock outbound requests, use @msw/cloudflare ↗︎. For setup instructions, refer to Mock outbound requests.

Was this helpful?