hono icon indicating copy to clipboard operation
hono copied to clipboard

Mocking cf context don't works

Open MatteoGauthier opened this issue 1 year ago • 1 comments

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

MatteoGauthier avatar Sep 16 '24 21:09 MatteoGauthier

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

yusukebe avatar Sep 17 '24 01:09 yusukebe

This issue has been marked as stale due to inactivity.

github-actions[bot] avatar Nov 03 '24 00:11 github-actions[bot]

Closing this issue due to inactivity.

github-actions[bot] avatar Nov 06 '24 00:11 github-actions[bot]