cloudflare / cloudflare/workers-sdk
[vitest-pool-workers] Support Vitest v5
- Dominant language
- TypeScript
- Stars
- 4.5k
- Forks
- 1.5k
- Avg merge
- 3d 8h
- Merged PRs (30d)
- 186
Description
### Describe the solution
Please update `@cloudflare/vitest-pool-workers` to support Vitest v5.
Vitest 5.0.0 was released on 2026-09-03 and is now the `latest` dist-tag on npm. The
current `@cloudflare/vitest-pool-workers@0.22.0` declares `vitest: ^4.1.0` in its
peer dependencies, so any project that installs Vitest from `latest` now gets a test
suite that fails before a single test runs.
Release notes: https://github.com/vitest-dev/vitest/releases/tag/v5.0.0
Tracking parallel to the previous major: #11064 (Vitest v4), #9521 (Vitest 3.2.x).
### Current behaviour
With `vitest@5.0.0` and `@cloudflare/vitest-pool-workers@0.22.0`, the pool fails to
start the worker and no tests execute:
```
[vpw:warn] You're running `vitest@5.0.0`, but this version of `@cloudflare/vitest-pool-workers` only officially supports `vitest ^4.1.0`.
`@cloudflare/vitest-pool-workers` currently depends on internal Vitest APIs that are not protected by semantic-versioning guarantees.
Your tests may work without issue, but we can not guarantee compatibility outside of the above version range.
uncaught exception; source = Uncaught (in promise); stack = SyntaxError: Unexpected identifier 'file'
uncaught exception; exception = workerd/jsg/_virtual_includes/iterator/workerd/jsg/value.h:1477: failed: jsg.SyntaxError: Unexpected
identifier 'file'
⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯
Error: [vitest-pool]: Failed to start cloudflare-pool worker for test files /app/w/test/index.spec.ts.
❯ node_modules/vitest/dist/chunks/index.B89dZ0-N.js:11469:97
Caused by: SyntaxError: Unexpected identifier 'file'
❯ ProxyServer.fetch node_modules/miniflare/src/workers/core/proxy.worker.ts:173:11
Test Files no tests
Tests no tests
Errors 1 error
```
The error surfaces in `proxy.worker.ts` while evaluating code sent into `workerd`,
which is consistent with the internal-Vitest-API coupling called out in the warning
rather than with anything in the test file itself.
### Additional detail: split dependency tree
Because `0.22.0` peers `@vitest/runner: ^4.1.0` and `@vitest/snapshot: ^4.1.0`
alongside `vitest: ^4.1.0`, installing `vitest@5` resolves an inconsistent tree —
the top-level `vitest` is v5 while the runner and snapshot packages stay on v4:
```
vitest = 5.0.0
@vitest/runner = 4.1.10
@vitest/snapshot = 4.1.10
@cloudflare/vitest-pool-workers = 0.22.0
```
Whatever shape v5 support takes, these three peer ranges will need to move together.
Note also that `vitest@5` widens its own `vite` peer range to
`^6.4.0 || ^7.0.0 || ^8.0.0`.
### Reproduction
Minimal repro against a queue-consumer Worker with a `cloudflareTest()` plugin config:
```ts
// vitest.config.mts
import { defineConfig } from 'vitest/config';
import { cloudflareTest } from '@cloudflare/vitest-pool-workers';
export default defineConfig({
plugins: [cloudflareTest({ wrangler: { configPath: './wrangler.jsonc' } })],
});
```
```jsonc
// package.json devDependencies
{
"@cloudflare/vitest-pool-workers": "^0.22.0",
"@cloudflare/workers-types": "^5.20260908.1",
"vitest": "~5.0.0",
"wrangler": "^4.129.1"
}
```
Then `bun install && bunx vitest run` → the error above. Pinning `vitest` back to
`~4.1.11` with no other change makes the same suite pass (5/5 tests).
### Versions & environment
- `@cloudflare/vitest-pool-workers` 0.22.0
- `vitest` 5.0.0 (fails) / 4.1.11 (passes)
- `wrangler` 4.129.1
- `miniflare` 5.20260815.0-alpha (via pool-workers)
- `@cloudflare/workers-types` 5.20260908.1
- Bun 1.4.2, Linux arm64 (`oven/bun:latest` container)
### Workaround
Pin `vitest` to the v4 line (`~4.1.11`, npm dist-tag `V4`) and hold there until a
pool-workers release accepts v5.
Contributor guide
Research direction
Start with the peer dependency declarations in package.json and the Vitest integration around proxy.worker.ts, then reproduce the failure with the listed vitest.config.mts and bunx vitest run command. Review the Vitest v5 release notes and align the vitest, @vitest/runner, and @vitest/snapshot ranges; done means the reproduction installs consistently and all 5 tests pass on Vitest v5.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- bun, typescript
- Domain
- testing
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 52/100