-
-
Notifications
You must be signed in to change notification settings - Fork 546
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
testClient does not open websockets for testing #3239
Comments
In short, you cannot use To test WebSockets in Bun, you have to run the actual server on like With |
Is it possible to have a websocket test helper planned for Hono? |
@yusukebe Yes. |
What version of Hono are you using?
4.5.1
What runtime/platform is your app running on?
Bun
What steps can reproduce the bug?
Step 1: Create a route with an upgrade to web socket handler.
Step 2a: Now have two variations of test files. Let's call the first one
withHc.test.ts
:Start the server on port 3000. Run the tests with
bun test
and you will see the console logs and the test passes 🥳Step 2b: Let's call the second test file
withClient.test.ts
:Don't start the server. Simply run
bun test
and the code will timeout 😢 . This is because the socket object from testClient never opens a connection.What is the expected behavior?
Any sockets created using
testClient
should also open connections on request. In a testing environment, it is important to have this helper work to maintain consistency around the project.What do you see instead?
testClient
does not open a connection so I cannot test websocket server on the route.Additional information
No response
The text was updated successfully, but these errors were encountered: