cloudflare / cloudflare/cloudflare-docs

cloudflare:test is not resolved when using @cloudflare/vitest-pool-workers in compilerOptions.types

Open
#30,069 3 comments 4 reactions 0 assignees View on GitHub
product:workers stale
Dominant language
MDX
Stars
5.2k
Forks
16.7k
Avg merge
2d 6h
Merged PRs (30d)
337

Description

### Example URL(s)

- https://developers.cloudflare.com/workers/testing/vitest-integration/write-your-first-test/
- https://developers.cloudflare.com/workers/testing/vitest-integration/test-apis/

### Actual Behavior

Following the docs, I added `@cloudflare/vitest-pool-workers` to `compilerOptions.types` and wrote a test importing from `cloudflare:test`.

TypeScript still reported:
`Cannot find module 'cloudflare:test' or its corresponding type declarations.`

In my setup, cloudflare:test only resolved after I changed the types entry from:
`"types": ["@cloudflare/vitest-pool-workers"]`
to:
`"types": ["@cloudflare/vitest-pool-workers/types"]`

### Expected Behavior

Using `@cloudflare/vitest-pool-workers` in `compilerOptions.types` should make `cloudflare:test` resolvable, as described in the docs.

If `@cloudflare/vitest-pool-workers/types` is actually required for some package versions, the docs should say that explicitly.

### Additional information

Environment:
- @cloudflare/vitest-pool-workers: 0.14.7
- vitest: 4.1.4
- wrangler: 4.21.2
- typescript: 5.8.3
- vite: 6.4.2
- @cloudflare/workers-types: 4.20260418.1

From inspecting the installed package, it looks like:
- the root package type entry points to the main plugin/config typings
- the ambient declare module "cloudflare:test" declaration is exposed via the ./types subpath

That appears to be why @cloudflare/vitest-pool-workers/types works while @cloudflare/vitest-pool-workers does not.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.