Skip to content

feat(wrangler): add binding overrides to test harness#14446

Open
edmundhung wants to merge 3 commits into
mainfrom
edmundhung/harness-binding-overrides
Open

feat(wrangler): add binding overrides to test harness#14446
edmundhung wants to merge 3 commits into
mainfrom
edmundhung/harness-binding-overrides

Conversation

@edmundhung

@edmundhung edmundhung commented Jun 26, 2026

Copy link
Copy Markdown
Member

Fixes n/a.


  • Tests
    • Tests included/updated
    • Automated tests not possible - manual testing has been completed as follows:
    • Additional testing not necessary because:
  • Public documentation
    • Cloudflare docs PR(s):
    • Documentation not necessary because: I will update the docs later

A picture of a cute animal (not mandatory, but encouraged)


Open in Devin Review

@changeset-bot

changeset-bot Bot commented Jun 26, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 4bc0083

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
wrangler Minor
@cloudflare/vite-plugin Patch
@cloudflare/vitest-pool-workers Patch

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

@github-project-automation github-project-automation Bot moved this to Untriaged in workers-sdk Jun 26, 2026
@workers-devprod workers-devprod requested review from a team and ascorbic and removed request for a team June 26, 2026 20:35
@workers-devprod

Copy link
Copy Markdown
Contributor

Codeowners approval required for this PR:

  • @cloudflare/wrangler
Show detailed file reviewers
  • .changeset/tiny-oranges-sip.md: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/README.md: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/package.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tests/vitest.test.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/tsconfig.json: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/vite.config.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/api/worker-configuration.d.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/mock-browser/index.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/mock-browser/wrangler.jsonc: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/web/index.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/web/worker-configuration.d.ts: [@cloudflare/wrangler]
  • fixtures/create-test-harness-example/workers/web/wrangler.jsonc: [@cloudflare/wrangler]
  • packages/wrangler/e2e/createTestHarness.test.ts: [@cloudflare/wrangler]
  • packages/wrangler/src/api/test-harness.ts: [@cloudflare/wrangler]

@ask-bonk

ask-bonk Bot commented Jun 26, 2026

Copy link
Copy Markdown
Contributor

Both 2026-05-29 (10 chars) and 2026-05-29.png (sliced to 10) resolve to the same date. Consistent.

The PR is well-implemented. The core logic correctly merges binding overrides via inputBindings precedence in getBindings, the overrides only apply to configPath workers (sensible), and tests cover the override, reset, and missing-target cases. The fixtures and types are consistent.

I reviewed PR #14446 thoroughly: the binding override mechanism (bindingOverridesservice bindings → inputBindings taking precedence in getBindings), the new getExport() API, the merge ordering against vars/secrets/config bindings, the reset flow, the fixture changes, and the date-slice change in the web worker. I found no logic bugs, security issues, backward-compatibility violations, or incorrect API behavior. The changes are well-tested (override, reset reload, missing-target error) and internally consistent.

LGTM

github run

@github-actions

Copy link
Copy Markdown
Contributor

✅ All changesets look good

@pkg-pr-new

pkg-pr-new Bot commented Jun 26, 2026

Copy link
Copy Markdown
@cloudflare/autoconfig

npm i https://pkg.pr.new/@cloudflare/autoconfig@14446

create-cloudflare

npm i https://pkg.pr.new/create-cloudflare@14446

@cloudflare/deploy-helpers

npm i https://pkg.pr.new/@cloudflare/deploy-helpers@14446

@cloudflare/kv-asset-handler

npm i https://pkg.pr.new/@cloudflare/kv-asset-handler@14446

miniflare

npm i https://pkg.pr.new/miniflare@14446

@cloudflare/pages-shared

npm i https://pkg.pr.new/@cloudflare/pages-shared@14446

@cloudflare/unenv-preset

npm i https://pkg.pr.new/@cloudflare/unenv-preset@14446

@cloudflare/vite-plugin

npm i https://pkg.pr.new/@cloudflare/vite-plugin@14446

@cloudflare/vitest-pool-workers

npm i https://pkg.pr.new/@cloudflare/vitest-pool-workers@14446

@cloudflare/workers-auth

npm i https://pkg.pr.new/@cloudflare/workers-auth@14446

@cloudflare/workers-editor-shared

npm i https://pkg.pr.new/@cloudflare/workers-editor-shared@14446

@cloudflare/workers-utils

npm i https://pkg.pr.new/@cloudflare/workers-utils@14446

wrangler

npm i https://pkg.pr.new/wrangler@14446

commit: 4bc0083

@devin-ai-integration devin-ai-integration Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

Open in Devin Review

Comment on lines +366 to +368
for (const [key, value] of Object.entries(workerBindingOverrides ?? {})) {
bindings[key] = { type: "service", service: value };
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚩 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.

Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Untriaged

Development

Successfully merging this pull request may close these issues.

2 participants