{
  "slug": "createtestharness-overrides-bindings-and-accesses-worker-exports-7c2ceab48e4d",
  "title": "createTestHarness() overrides bindings and accesses Worker exports",
  "tools": [
    "wrangler"
  ],
  "tags": [
    "agent"
  ],
  "introduced_at": "2026-06-30T16:38:09.000Z",
  "announced_at": "2026-06-30T16:38:09.000Z",
  "effective_at": null,
  "date_basis": "source-publication",
  "status": "unknown",
  "how": {
    "incantation": "When a config-backed Worker needs a mock for a service binding, set `bindingOverrides` to the mock Worker’s harness name. To control the mock, call `getExport()` on `server.getWorker(name)` and use its default export’s RPC methods.",
    "examples": [
      "import { createTestHarness } from \"wrangler\";\n\nconst server = createTestHarness({\n  workers: [\n    {\n      configPath: \"<path-to-worker-wrangler-config>\",\n      bindingOverrides: { <BINDING_NAME>: \"<mock-worker-name>\" },\n    },\n    { configPath: \"<path-to-mock-worker-wrangler-config>\" },\n  ],\n});\n\nconst mock = await server.getWorker(\"<mock-worker-name>\").getExport();\nawait mock.<rpcMethod>(<arguments>);"
    ],
    "gotchas": [
      "Version: wrangler@4.106.0",
      "bindingOverrides: A record mapping binding names in this Worker's environment to Worker names in this test harness.",
      "configPath (required): Path to a Wrangler configuration file; relative paths resolve from `root`.",
      "server.getWorker(name): Returns a Worker handle; omit the name to select the primary Worker.",
      "getExport(): Returns the default Worker export, including RPC methods.",
      "Prerequisite: Import `createTestHarness` from `wrangler`; use Node.js test runner environment. The harness runs production build output from Wrangler config files, Vite-generated configs, or inline Wrangler config objects.",
      "This applies to test harness Workers loaded from Wrangler config files.",
      "Binding overrides can target a Worker in the same harness.",
      "`getExport()` is called on a Worker returned by `server.getWorker(name)` and accesses JSRPC methods on its default Worker export."
    ]
  },
  "why_it_matters": "Test a Worker that depends on a platform binding by replacing it with a mock Worker and controlling the mock's exported methods.",
  "sources": [
    "https://github.com/cloudflare/workers-sdk/releases/tag/wrangler%404.106.0",
    "https://developers.cloudflare.com/workers/wrangler/api/"
  ],
  "rank": 0.9602,
  "judge": {
    "publish": true,
    "judge_model": "codex-cli/gpt-6-luna+typesafe/jev-1.13.0",
    "prompt_version": "extract-v7+enrich-v1+judge-v2x3+jev-publish-v1"
  },
  "review_state": "approved",
  "provenance": {
    "run_id": "backfill-20261007",
    "verdict_id": "backfill-20261007:backfill-20261007-2841bfddc8d257e6-6:gate",
    "evidence_hash": "630dc99354ee14d0aca270af3150e2f48682af60af86551fa937bfdb7badd326"
  },
  "review": {
    "draft_hash": "eec030ad825b2d12ae4b585909fee4c2149bfa36f7154e95fbc115ba9d79f870",
    "reviewer": "publication-gate",
    "reviewed_at": "2026-10-07T00:00:00.000Z",
    "decision": "backfill-20261007:gate",
    "reason": "3 of 3 judge runs approved with p_yes >= 0.9 (mean 0.96 >= 0.9; 2 needed) and Jev gave 0.77 (>= 0.6 needed)."
  }
}
