sincecutoff.com
← all changes

wrangler createTestHarness Worker handles expose getEnv()

Introduced 2026-06-23 · score 0.97

HOW TO USE IT

When inspecting a Worker environment in a `createTestHarness()` test, call `await server.getWorker<Env>().getEnv()` to read its configured variables, secrets, and bindings.

const env = await server.getWorker<Env>().getEnv();

WHY THIS HELPS

Inspect a test harness Worker’s environment while testing code that uses its vars, secrets, or bindings.

REQUIREMENTS AND LIMITATIONS

  • Version: 4.104.0
  • Env: Type argument for the Worker environment; define it manually or generate it from Wrangler configuration.
  • getEnv() (required): Takes no arguments; returns the Worker’s full configured environment, including variables, secrets, and bindings.
  • Prerequisite: Use a Worker project with a Wrangler configuration file, a Node.js test runner, and `wrangler` installed as a development dependency.

FIRST-PARTY EVIDENCE

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

Report a problem with this card