Skip to content
New issue

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

fix bun test example #236

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions getting-started/bun.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default app // [!code --]
export default { // [!code ++]
port: 3000, // [!code ++]
fetch: app.fetch, // [!code ++]
request: app.request, // [!code ++]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not necessary.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When you say "this is not needed", does that mean you can use app.request without it?
Please tell me why it is not necessary.

Without this line, in my environment(bun 1.0.26, hono 4.0.1, 3.12.12) I get an error like this.

スクリーンショット 2024-02-12 0 42 48

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume the following case where the port number is not changed.

const app = new Hono()

// ...

export default app

The exported application contains the request property.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, I understand that if "app" is exported, it has a request property. This proposal is to use "app.request" when "app" is not exported with port change. If you don't need that, then so be it. Thank you.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for understanding. I want to keep it simple here, so can you please remove that line?

} // [!code ++]
```

Expand Down Expand Up @@ -147,8 +148,7 @@ import app from '.'

describe('My first test', () => {
it('Should return 200 Response', async () => {
const req = new Request('http://localhost/')
const res = await app.fetch(req)
const res = await app.request('/')
expect(res.status).toBe(200)
})
})
Expand Down