sincecutoff.com
← all changes

createTestHarness() introspects Workflow bindings

Introduced 2026-06-30 · score 0.98

HOW TO USE IT

When a Worker route starts a Workflow, use `createTestHarness()` to introspect its binding, disable the named sleep, trigger the route, and wait for the instance to complete.

const harness = createTestHarness({ workers: [{ configPath: "./wrangler.json" }] }); const worker = harness.getWorker(); await using workflow = await worker.introspectWorkflow("MY_WORKFLOW"); await workflow.modifyAll(async (modifier) => { await modifier.disableSleeps([{ name: "wait-for-approval" }]); }); await worker.fetch("/start-workflow"); const [instance] = await workflow.get(); await instance.waitForStatus("complete");

WHY THIS HELPS

Test a Worker route that starts a Workflow and wait for the resulting Workflow instance to complete.

REQUIREMENTS AND LIMITATIONS

  • Version: wrangler@4.106.0
  • workers[].configPath (required): Path to the Worker Wrangler configuration file.
  • bindingName (required): Workflow binding name to introspect; instances created after introspection starts are captured.
  • disableSleeps([{ name }]): Disables the specified Workflow sleep; `name` identifies the sleep step.
  • waitForStatus(status) (required): Waits until the instance reaches the requested status; use `"complete"` here.
  • Prerequisite: A Worker project with a Wrangler configuration file, a Node.js test runner, and `wrangler` installed as a development dependency.
  • Introspection is by Workflow binding name.
  • Tests can introspect a known Workflow instance by ID or track instances created after introspection starts.
  • Docs conflict: Current documentation was last updated July 27, 2026, after Wrangler 4.106.0. Its example uses an async `modifyAll` callback and awaits `disableSleeps`; the release-note example uses a synchronous callback. The release note is retained for the target version.

FIRST-PARTY EVIDENCE

Check the installed version and the source before using it. Entry JSON

Report a problem with this card