Skip to content

test(cloudflare-workers): add coverage for onClose, onError, send, and close in Cloudflare Workers websocket adapter - #5145

Merged
yusukebe merged 1 commit into
honojs:mainfrom
nikachello:test/cloudflare-workers-websocket-coverage
Jul 24, 2026
Merged

test(cloudflare-workers): add coverage for onClose, onError, send, and close in Cloudflare Workers websocket adapter#5145
yusukebe merged 1 commit into
honojs:mainfrom
nikachello:test/cloudflare-workers-websocket-coverage

Conversation

@nikachello

Copy link
Copy Markdown
Contributor

Summary

Adds tests for previously untested code in the Cloudflare Workers websocket
adapter (src/adapter/cloudflare-workers/websocket.ts):

  • onClose event handling
  • onError event handling
  • WSContext.send()
  • WSContext.close()

Why

While looking at #4603, I noticed these code paths had no test coverage
(lines 22, 31, 37, 43). This doesn't fix that issue, but adds regression
protection around the close/error/send handling it touches on.

Coverage for this file went from 73.91% statements / 60% branch / 50%
functions to 100% statements / 90% branch / 100% functions.

Testing

bun run test passes locally.

@codecov

codecov Bot commented Jul 21, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 79.07%. Comparing base (cadff88) to head (21c7c33).
⚠️ Report is 3 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5145      +/-   ##
==========================================
+ Coverage   79.04%   79.07%   +0.03%     
==========================================
  Files         154      154              
  Lines       10779    10779              
  Branches     2256     2256              
==========================================
+ Hits         8520     8524       +4     
+ Misses       2259     2255       -4     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yusukebe yusukebe changed the title test: add coverage for onClose, onError, send, and close in Cloudflare Workers websocket adapter test(cloudflare-workers): add coverage for onClose, onError, send, and close in Cloudflare Workers websocket adapter Jul 24, 2026
@yusukebe
yusukebe merged commit a88c89d into honojs:main Jul 24, 2026
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants