honojs / hono

Web framework built on Web Standards
https://hono.dev
MIT License
20.38k stars 584 forks source link

Mocking cf context don't works #3418

Closed MatteoGauthier closed 1 week ago

MatteoGauthier commented 2 months ago

What version of Hono are you using?

hono

What runtime/platform is your app running on?

Bun with Vitest for testing

What steps can reproduce the bug?

Simple repro repository

https://github.com/MatteoGauthier/hono-repro-context-cf-mock

bun test:ui

What is the expected behavior?

Using this syntax

    const req = new Request(`http://localhost/context`, {
      cf: {
        timezone: "Europe/Paris",
      },
    })

    const res = await app.request(req, {})

It should be possible to mock the ctx.raw.cf

What do you see instead?

undefined

Additional information

No response

yusukebe commented 2 months ago

Hi @MatteoGauthier

This is not a Hono-side issue, but you can refer to this implementation: https://github.com/honojs/vite-plugins/blob/main/packages/dev-server/src/adapter/cloudflare.ts#L31-L40

github-actions[bot] commented 2 weeks ago

This issue has been marked as stale due to inactivity.

github-actions[bot] commented 1 week ago

Closing this issue due to inactivity.