feat(wrangler): add binding overrides to test harness#14446
Conversation
🦋 Changeset detectedLatest commit: 4bc0083 The changes in this PR will be included in the next version bump. This PR includes changesets to release 3 packages
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 |
|
Codeowners approval required for this PR:
Show detailed file reviewers
|
|
Both The PR is well-implemented. The core logic correctly merges binding overrides via I reviewed PR #14446 thoroughly: the binding override mechanism ( LGTM |
|
✅ All changesets look good |
@cloudflare/autoconfig
create-cloudflare
@cloudflare/deploy-helpers
@cloudflare/kv-asset-handler
miniflare
@cloudflare/pages-shared
@cloudflare/unenv-preset
@cloudflare/vite-plugin
@cloudflare/vitest-pool-workers
@cloudflare/workers-auth
@cloudflare/workers-editor-shared
@cloudflare/workers-utils
wrangler
commit: |
| for (const [key, value] of Object.entries(workerBindingOverrides ?? {})) { | ||
| bindings[key] = { type: "service", service: value }; | ||
| } |
There was a problem hiding this comment.
🚩 Binding override priority depends on getBindings() merge behavior
The binding overrides are set in input.bindings at packages/wrangler/src/api/test-harness.ts:366-368. In ConfigController.ts:281-284, the final bindings are constructed as { ...input.bindings, ...bindings } where bindings comes from resolveBindings() / getBindings(). At first glance this spread order would let config-resolved bindings overwrite the overrides. However, getBindings() receives input.bindings as a parameter and is expected to merge them with the right priority. The e2e tests at packages/wrangler/e2e/createTestHarness.test.ts:444-526 confirm that overrides work correctly (AI binding is replaced, call counter resets on server.reset()). Still, the correctness depends on an implicit contract in getBindings() that isn't documented — if getBindings() ever changes its merge strategy, binding overrides could silently stop working.
Was this helpful? React with 👍 or 👎 to provide feedback.
Fixes n/a.
A picture of a cute animal (not mandatory, but encouraged)