/Knowledge/sources/honojs__hono/llms-full/testing-request-and-response--part-05--d86020133baf.md
Testing: Request and Response (part 05) - hono-docs
Testing: Request and Response (part 05) Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt request and re...
Testing: Request and Response (part 05)
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#request-and-response
Summary
You can also pass an instance of the Request class. ```ts test('POST /posts', async () => { const req = new Request('http://localhost/posts', { method: 'POST', }) const res = await app.request(req) expect(res.status).toBe(201) expect(res...
Content
You can also pass an instance of the Request class.
test('POST /posts', async () => {
const req = new Request('http://localhost/posts', {
method: 'POST',
})
const res = await app.request(req)
expect(res.status).toBe(201)
expect(res.headers.get('X-Custom')).toBe('Thank you')
expect(await res.json()).toEqual({
message: 'Created',
})
})
In this way, you can test it as like an End-to-End.
Metadata
{
"chunk_index": 4,
"citation": "https://hono.dev/llms-full.txt#request-and-response",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Testing > Request and Response (5)",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 98,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Testing: Request and Response (part 05)",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}