We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
getConnInfo
4.6.3
Bun
git clone https://github.com/mrcaidev/bun-hono-getconninfo-reproduction.git cd bun-hono-getconninfo-reproduction bun i bun test
getConnInfo should not fail in testing environment.
bun test v1.1.29 (6d43b366) src/index.test.ts: 1 | // src/adapter/bun/server.ts 2 | var getBunServer = (c) => "server" in c.env ? c.env.server : c.env; ^ TypeError: c.env is not an Object. (evaluating '"server" in c.env') at getBunServer (/home/mrcaidev/bun-hono-getconninfo-reproduction/node_modules/hono/dist/adapter/bun/server.js:2:39) at getConnInfo (/home/mrcaidev/bun-hono-getconninfo-reproduction/node_modules/hono/dist/adapter/bun/conninfo.js:4:18) at /home/mrcaidev/bun-hono-getconninfo-reproduction/src/index.ts:7:17 at dispatch (/home/mrcaidev/bun-hono-getconninfo-reproduction/node_modules/hono/dist/hono-base.js:187:36) at /home/mrcaidev/bun-hono-getconninfo-reproduction/src/index.test.ts:6:27 at /home/mrcaidev/bun-hono-getconninfo-reproduction/src/index.test.ts:5:26 2 | import app from './index' 3 | 4 | describe('GET /', () => { 5 | it('should return IP', async () => { 6 | const res = await app.request('/') 7 | expect(res.status).toEqual(200) ^ error: expect(received).toEqual(expected) Expected: 200 Received: 500 at /home/mrcaidev/bun-hono-getconninfo-reproduction/src/index.test.ts:7:24 ✗ GET / > should return IP [2.43ms] 0 pass 1 fail 1 expect() calls Ran 1 tests across 1 files. [66.00ms]
Is it because Hono does not set up a real server when testing?
If it is, is there any workaround? Otherwise, I have to manually skip getConnInfo with process.env.NODE_ENV === "test" or similar codes every time.
process.env.NODE_ENV === "test"
The text was updated successfully, but these errors were encountered:
Hi @mrcaidev
Yes. But, you can pass the server info as a 3rd argument on app.request():
app.request()
const res = await app.request( '/', {}, { server: { requestIP: () => { return { address: '127.0.0.1', family: 'foo', port: '123' } } } } )
It's like a workaround, but this is the best way.
Sorry, something went wrong.
test: workaround for honojs/hono#3460
de8926f
ipRestrictions
No branches or pull requests
What version of Hono are you using?
4.6.3
What runtime/platform is your app running on?
Bun
What steps can reproduce the bug?
What is the expected behavior?
getConnInfo
should not fail in testing environment.What do you see instead?
Additional information
Is it because Hono does not set up a real server when testing?
If it is, is there any workaround? Otherwise, I have to manually skip
getConnInfo
withprocess.env.NODE_ENV === "test"
or similar codes every time.The text was updated successfully, but these errors were encountered: