Support Vitest 4 in @cloudflare/vitest-pool-workers#11632
Merged
Conversation
🦋 Changeset detectedLatest commit: 405a192 The changes in this PR will be included in the next version bump. Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
107ac9f to
e018115
Compare
create-cloudflare
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-editor-shared
wrangler
commit: |
penalosa
commented
Dec 17, 2025
packages/vitest-pool-workers/src/worker/lib/cloudflare/test-runner.ts
Outdated
Show resolved
Hide resolved
e28ec0a to
d45260d
Compare
Contributor
|
Claude encountered an error —— View job Reviewing Changesets
|
d45260d to
60332b7
Compare
b4ce401 to
964012e
Compare
ascorbic
reviewed
Dec 19, 2025
packages/vitest-pool-workers/src/pool/cloudflare-pool-worker.ts
Outdated
Show resolved
Hide resolved
Contributor
|
Codeowners approval required for this PR:
Show detailed file reviewers |
Contributor
|
✅ All changesets look good |
f44feba to
343ffb9
Compare
Co-authored-by: devin-ai-integration[bot] <158243242+devin-ai-integration[bot]@users.noreply.github.com>
taylorlee
approved these changes
Mar 6, 2026
pombosilva
approved these changes
Mar 6, 2026
…tsconfig Use the dynamic env from cloudflare:workers (live ESM binding) instead of the static this.env captured at WorkerEntrypoint construction. This allows withEnv() overrides to propagate through exports.default.fetch() and RPC calls to user handler invocations. Also fix workers-assets root tsconfig to only include ./*.ts, matching the pattern used by all other fixtures. The src/ and test/ subdirectories have their own tsconfigs with the correct workers types.
…pport # Conflicts: # pnpm-lock.yaml
singleWorker was removed from the pool options schema but was still being passed in console.test.ts and inspector.test.ts — silently stripped by Zod validation. Also expand the inline comment for no_handle_cross_request_promise_resolution to explain what it does and why it's needed.
Call worker.fetch() directly inside withEnv() so the overridden env is visible to the handler. exports.default.fetch() goes through service binding dispatch which creates a new request context — needs runtime team input on whether withEnv() should propagate across that boundary.
Merged
5 tasks
This was referenced Mar 19, 2026
5 tasks
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Fixes #11064
Fixes #10260 (tests added to verify the mentioned libraries can be imported)
Fixes #9957 (
providedata moved from HTTP headers to WebSocket messages, removing the ~8 KB size limit)Fixes #8369 (
defineWorkersConfigis removed)Fixes #7795 (everything is now encapsulated in a plugin, and so this type of configuration problem is impossible)
Fixes #7717 (leaked FSWatcher from Pages ASSETS binding is now closed via AbortSignal on pool worker stop)
Fixes #7339 (we no longer recommend importing
envfromcloudflare:test. Instead, importenvfromcloudflare:workersand usewithEnvto override the value: https://developers.cloudflare.com/workers/runtime-apis/bindings/#overriding-env-values)Fixes #7324 (
nodejs_compat_v2and Node module flags are now forcibly enabled during tests)Fixes #7288 (new
WorkersSnapshotEnvironmentproxies snapshot file operations over a service binding)Fixes #6465 (
workerdresolve condition is explicitly included,nodecondition is removed)Fixes #6214 (bare Node.js specifiers like
"url"are resolved by prependingnode:in the module fallback)Fixes #5592 (SSR optimizer replaced with
server.deps.inline = true, so Stripe resolves to its worker build)Fixes #5396 (module graph is now populated via standard Vitest
PoolWorkerRPC — the UI should work)Fixes #11690, fixes #11031, fixes #7707, fixes #5524 (Per-test isolated storage is completely removed, and so the entire mechanism that caused this is gone)
Fixes #6391 (fetch mock is now removed entirely)
This a breaking change to the
@cloudflare/vitest-pool-workersintegration in order to support Vitest v4. Along with supporting Vitest v4 (and dropping support for Vitest v2 and v3), we've made a number of changes that may require changes to your tests. Our aim has been to improve stability & the foundations of@cloudflare/vitest-pool-workersas we move towards a v1 release of the package.We've made a codemod to make the migration easier:
wrangler codemod vitest-pool-v3-to-v4, which will make the required changes to your config file.isolatedStorage&singleWorker: These have been removed in favour of a simpler isolation model that more closely matches Vitest. Storage isolation is now on a per test file basis, and you can make your test files share the same storage by using the Vitest flags--max-workers=1 --no-isolateimport { env, SELF } from "cloudflare:test": These have been deprecated in favour ofimport { env, exports } from "cloudflare:workers".exports.default.fetch()has the same behaviour asSELF.fetch(), except that it doesn't expose Assets. To test your assets, use theenv.ASSETSbindings or write an integration test usingstartDevWorker()(recommended)import { fetchMock } from "cloudflare:test": This has been removed. Instead, mockglobalThis.fetchor use ecosystem libraries like MSW (recommended).A picture of a cute animal (not mandatory, but encouraged)
