Wrangler - unstable_dev - simulate request.cf

Hi there!

We are currently developing a feature based on geolocation.

The actual code utilizes:
const clientRegion = request?.cf?.regionCode;
const clientCountry = request?.cf?.country;

To facilitate our integration testing, we plan to use unstable_dev. Is there a way to explicitly set the value of any property in request.cf?

Thank you!

@jfnault you can’t currently do this via unstable_dev, but you can via Miniflare - https://miniflare.dev/core/fetch. You can see an example test that changes cf here: https://github.com/cloudflare/workers-sdk/blob/e41049153f8e8f37a34d6d09f57473616e3e6e42/packages/miniflare/test/index.spec.ts#L477

Thank for your answer @amurray.

The only thing, with miniflare, it to not manage the esbuild part I think. I a bit more complicated to use existing project files.