Skip to content

Feat: add e2e request body parsing test#98

Merged
VikramAditya33 merged 1 commit into
mainfrom
e2e/test
May 7, 2026
Merged

Feat: add e2e request body parsing test#98
VikramAditya33 merged 1 commit into
mainfrom
e2e/test

Conversation

@VikramAditya33
Copy link
Copy Markdown
Collaborator

@VikramAditya33 VikramAditya33 commented May 7, 2026

E2E Tests added:

  • JSON body parsing (small, large, empty)
  • URL-encoded body parsing
  • Text body parsing (UTF-8)
  • Raw body parsing
  • Compressed bodies (gzip, deflate)
  • Body size limits and 413 rejection
  • Invalid JSON handling
  • Content-Type validation

Closes #96

Summary by CodeRabbit

  • Tests

    • Added comprehensive end-to-end body parsing test suite covering JSON, text, URL-encoded, and compressed payloads.
    • Improved test coverage for abort scenarios and decompression handling.
    • Added Jest E2E configuration and organized test scripts (test:integration, test:e2e, test:watch, test:cov).
  • Bug Fixes

    • Improved handling of chained content encodings with proper error responses.
    • Enhanced resource cleanup for decompression streams on connection abort.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 7, 2026

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: b5ae7409-7966-4f39-a990-56d44b5c2c02

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The PR title 'Feat: add e2e request body parsing test' directly and accurately summarizes the main change: adding an end-to-end test suite for request body parsing.
Linked Issues check ✅ Passed The PR implements all coding requirements from issue #96: JSON parsing (small/large/empty), URL-encoded parsing, text parsing, raw body parsing, compressed bodies (gzip/deflate), body size limits with 413 responses, invalid JSON handling, and Content-Type validation.
Out of Scope Changes check ✅ Passed The PR includes supporting changes beyond the test file (eslint.config.mjs, package.json, request.ts, request.spec.ts, jest.e2e.config.js) that are directly necessary for the E2E test implementation and infrastructure.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch e2e/test

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 2026

uWestJS Benchmark Results

Scenario Express req/s Fastify req/s uWestJS req/s Express throughput Fastify throughput uWestJS throughput uWestJS vs Express uWestJS vs Fastify
compression 6.50k 5.29k 7.96k 3.42 MB/s 2.71 MB/s 3.66 MB/s 1.22x 1.50x
headers 20.99k 36.08k 62.32k 3.90 MB/s 6.74 MB/s 9.81 MB/s 2.97x 1.73x
hello-world 22.59k 37.35k 73.82k 3.75 MB/s 6.27 MB/s 7.32 MB/s 3.27x 1.98x
json-response 20.68k 36.13k 65.32k 5.64 MB/s 9.89 MB/s 15.95 MB/s 3.16x 1.81x
mixed-response 21.25k 37.52k 59.45k 4.91 MB/s 8.69 MB/s 12.02 MB/s 2.80x 1.58x
post-json 19.32k 17.43k 33.77k 3.58 MB/s 4.75 MB/s 5.73 MB/s 1.75x 1.94x
query-params 17.69k 31.60k 65.89k 3.90 MB/s 6.99 MB/s 8.86 MB/s 3.73x 2.09x
route-params 21.00k 35.47k 58.04k 4.79 MB/s 8.12 MB/s 11.57 MB/s 2.76x 1.64x
static-file 23.72k 31.51k 50.80k 235.42 MB/s 312.32 MB/s 502.69 MB/s 2.14x 1.61x
streaming-upload 207.20 201.31 217.66 46.13 KB/s 42.07 KB/s 42.09 KB/s 1.05x 1.08x
streaming-with-content-length 418.18 409.90 420.00 2.04 GB/s 2.00 GB/s 2.05 GB/s 1.00x 1.02x
streaming-without-content-length 413.51 408.75 411.05 2.02 GB/s 2.00 GB/s 2.01 GB/s 0.99x 1.01x

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🧹 Nitpick comments (1)
test/http/body-parsing.e2e.spec.ts (1)

239-252: ⚡ Quick win

Repeated-key URL-encoded assertion should validate values, not just presence.

toBeDefined() is too loose; assert exact shape/value(s) to lock behavior (e.g., array or deterministic merge policy).

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@test/http/body-parsing.e2e.spec.ts` around lines 239 - 252, The test "should
handle array-like parameters" currently only checks presence of parsed.tags;
replace that loose assertion with a deterministic value check: call fetch to
`${baseUrl}/body-test/urlencoded`, parse JSON into parsed, then assert
parsed.tags equals the expected array ['javascript','typescript','nodejs'] (or
the exact merge policy your body parser uses) so the test validates the actual
values/shape for the endpoint handling repeated URL-encoded keys.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@package.json`:
- Around line 16-18: The Jest path patterns in package.json scripts (test:unit
and test:integration) use unescaped dots which act as "any character" in regex;
update the patterns for "test:unit" (the --testPathIgnorePatterns value) and
"test:integration" (the --testPathPatterns value) to escape all literal dots
(e.g., change ".integration.spec.ts" and ".e2e.spec.ts" to use escaped dots like
"\.integration\.spec\.ts" and "\.e2e\.spec\.ts" ensuring the JSON string
contains the necessary backslash escaping) so the CLI regex matches the exact
filenames; keep the "test:e2e" script unchanged.

In `@test/http/body-parsing.e2e.spec.ts`:
- Around line 42-47: Add an end-to-end test that exercises the echoBuffer POST
route to verify raw/binary body parsing: send a binary payload (e.g., Buffer of
known bytes) to the 'buffer' endpoint with Content-Type:
application/octet-stream, then assert the response's length equals the buffer
length and the data field equals the buffer encoded as base64; locate the
handler echoBuffer in the controller and the test file
test/http/body-parsing.e2e.spec.ts to add this assertion so raw/binary behavior
is covered for issue `#96`.
- Around line 125-134: The test "should handle empty JSON body for POST (should
throw)" currently uses a permissive assertion (response.status >= 400); replace
it with an explicit expected status check (e.g.,
expect(response.status).toBe(400) or toBe(415) depending on the server's
intended behavior) and document which specific status is authoritative for this
scenario; likewise update the other tests called out in the review (the nearby
POST/JSON tests and the blocks around the other reported ranges) to assert exact
expected statuses (use toBe or a clear toEqual/toContain matcher against a small
explicit array if multiple statuses are acceptable) instead of broad ranges like
>= 400 or >= 200 so failures map to a precise regression and the intended
behavior is clear.
- Around line 255-309: Add a new test case inside the "Text Body Parsing"
describe block (near the other it() tests) named something like "should handle
UTF-16 text" that sends the same endpoint `/body-test/text` but supplies a
UTF‑16 encoded request body and a Content-Type including charset=utf-16;
construct the body as a Node Buffer encoded in UTF‑16 (include the BOM, e.g.
prepend 0xFF 0xFE and use 'utf16le' encoding) and send that Buffer as the fetch
body, then assert response.status is 200 and response.text() equals the original
Unicode string; this will cover the missing UTF‑16 parsing objective for the
tests around the endpoint used in the file.

---

Nitpick comments:
In `@test/http/body-parsing.e2e.spec.ts`:
- Around line 239-252: The test "should handle array-like parameters" currently
only checks presence of parsed.tags; replace that loose assertion with a
deterministic value check: call fetch to `${baseUrl}/body-test/urlencoded`,
parse JSON into parsed, then assert parsed.tags equals the expected array
['javascript','typescript','nodejs'] (or the exact merge policy your body parser
uses) so the test validates the actual values/shape for the endpoint handling
repeated URL-encoded keys.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: ab16f3df-f05c-42d7-991e-7f8986fc5ee3

📥 Commits

Reviewing files that changed from the base of the PR and between 8805ef2 and 18e49e3.

📒 Files selected for processing (6)
  • eslint.config.mjs
  • package.json
  • src/http/core/request.spec.ts
  • src/http/core/request.ts
  • test/http/body-parsing.e2e.spec.ts
  • test/jest.e2e.config.js

Comment thread package.json
Comment thread test/http/body-parsing.e2e.spec.ts
Comment thread test/http/body-parsing.e2e.spec.ts
Comment thread test/http/body-parsing.e2e.spec.ts
@VikramAditya33 VikramAditya33 merged commit a0f02ab into main May 7, 2026
4 checks passed
@VikramAditya33 VikramAditya33 deleted the e2e/test branch May 7, 2026 18:54
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.

Request Body Parsing Test

1 participant