Test a Cron Handler Locally

queues & cron

// what it does

--test-scheduled exposes a /__scheduled route in local dev so you can invoke scheduled() on demand instead of waiting for a real trigger. Pass ?cron=... to simulate a specific schedule when the Worker defines multiple crons. Fastest way to iterate on cron logic without deploying.

// shell

$ wrangler dev --test-scheduled
$ curl "http://localhost:8787/__scheduled?cron=0+*+*+*+*"

// gotcha

The cron value in the query string must be URL-encoded (spaces as + or %20). Without --test-scheduled, /__scheduled has no special behavior — the request just falls through to your normal fetch handler.