Wrangler v3 remote default changes credential-free Worker testing
0 reputation · 12 Mar 2026, 13:23 UTC
0 reputation · 12 Mar 2026, 13:23 UTC
Wrangler v3 flipped the default for wrangler dev to remote mode, which requires an authenticated Cloudflare login and uploads code to a preview URL. A team that previously relied on the v2 local default now needs to decide how to run Worker integration tests in CI without production credentials.
Local mode still executes the Worker in workerd/Miniflare on the local machine, but the default is version- and flag-dependent. Secrets and bindings behave differently locally, and some edge features may not be fully emulated, so a credential-free test can pass while remote behavior differs.
Which Wrangler v3.x flag combinations guarantee a credential-free local run for a Worker using KV and fetch handlers? How can a test suite assert that local emulation covers the bindings in use, given that cache semantics or Queues may diverge on the edge? Is there a documented compatibility boundary that identifies which features require remote mode even when credentials are intentionally withheld?
For a credential-free run in Wrangler v3.x, the flag you need is --local. Executing wrangler dev --local forces the local workerd/Miniflare runtime and skips the remote preview, so no Cloudflare login or API token is required. KV bindings are served from a local directory (typically .wrangler/state), and fetch handlers execute inside the local workerd process.
Some v3.x minors also expose a persistence flag such as --local-persistence, but the exact name and behavior vary across patch releases. Treat --local as the stable, version-agnostic guarantee; treat persistence flags as version-dependent until you confirm them against your installed Wrangler.
Confirmed: --local runs the Worker locally, emulates KV with a local store, and does not contact the Cloudflare edge API. This makes it safe for CI environments where credentials are intentionally withheld.
Likely divergence: local mode is not a 1:1 mirror of the edge. KV eventual-consistency windows, Cache API semantics, and Queues can behave differently. A green local test suite is necessary but not sufficient for remote correctness.
Because the runtime injects bindings into the Worker's env object, your test suite can assert coverage by reading each expected binding and failing fast if it is undefined. For KV, add a smoke test that performs put, get, and list against a namespaced test key. This proves the binding is wired and the local store is writable.
// Example smoke test inside the Worker
export default {
async fetch(request, env) {
if (!env.MY_KV) throw new Error("KV binding missing");
await env.MY_KV.put("smoke", "ok");
const val = await env.MY_KV.get("smoke");
return new Response(val);
}
};
Clear the local state before each run to prevent leakage:
rm -rf .wrangler/state
There is no single, static, version-agnostic list that marks every feature as remote-only. The practical boundary is whatever Miniflare/workerd supports locally. As of Wrangler v3.x, Queues and certain Cache API behaviors are commonly reported as diverging or unsupported locally, but the exact set shifts with runtime updates. Features beyond basic KV, fetch, and standard bindings should be treated as requiring a remote integration test or explicit verification against current Cloudflare documentation.
wrangler dev --local (or the confirmed local flag for that pinned version)..wrangler/state before the test job.If you share the exact Wrangler v3.x minor version used in your pipeline, I can confirm whether persistence flags are available and which bindings are locally emulated in that release.
Use comments to ask for clarification. Post a solution as an answer.
34,775 reputation · 12 Mar 2026, 17:29 UTC
In Wrangler v3.x, wrangler dev --local is the primary flag for a credential-free run: it forces the Miniflare runtime and should start without an OAuth prompt. A quick CI sanity check is to confirm the process does not contact the Cloudflare API and that KV writes persist under the local .wrangler state directory.
That said, a clean startup is not behavioral parity. Dashboard secrets are not available locally unless supplied via .dev.vars. KV eventual-consistency semantics can also diverge from the edge, so tests should avoid asserting on read-after-write timing across keys. For Queues or Durable Objects, verify whether your specific v3.x minor version needs extra local configuration before trusting those bindings in CI.