parseResponse snapshot test fails when a server is listening on localhost:80
What version of Hono are you using?
main branch, commit 6cadf753
What runtime/platform is your app running on? (with version if possible)
Windows 11, Node v22.15.1, Bun 1.4.2
What steps can reproduce the bug?
- Have any HTTP server listening on port 80 (in my case IIS 10.0, which ships with Windows)
- Run: bunx vitest run src/client/utils.test.ts
- With IIS stopped (Stop-Service W3SVC), all 32 tests pass
What is the expected behavior?
The test passes regardless of what is running on the host machine.
What do you see instead?
Expected: "[TypeError: fetch failed]" Received: "[DetailedError: 404 Not Found]"
Additional information
Title: parseResponse snapshot test fails when a server is listening on localhost:80
What happens
src/client/utils.test.ts > parseResponse > should throw error matching snapshots fails on my machine:
- Expected:
[TypeError: fetch failed] - Received:
[DetailedError: 404 Not Found]
Cause
The request to http://localhost/noRoute has no MSW handler (MSW logs an
"intercepted a request without a matching request handler" warning), so it
goes to the real network. On CI nothing listens on port 80, so fetch fails
as the snapshot expects. On my machine IIS 10.0 is listening on port 80 and
returns a 404, so the client throws a DetailedError instead.
Reproduction
With IIS 10.0 running on port 80, the test fails. With IIS stopped
(Stop-Service W3SVC), all 32 tests in src/client/utils.test.ts pass.
The MSW warning appears in both runs, so the request reaches the real
network either way; the result depends only on whether something is
listening on port 80.
Proposed fix
Register an explicit MSW handler for that route that simulates a network error, so the test's outcome no longer depends on what is running on the host. Happy to open a PR if that approach sounds right.
Environment
Windows 11, Bun 1.4.2, Node v22.15.1
Source: honojs/hono