/Knowledge/sources/honojs__hono/llms-full/testing-env--00183354866d.md
Testing: Env - hono-docs
Testing: Env Source evidence: /Sources/honojs hono/provenance.md Canonical citation: https://hono.dev/llms full.txt env Summary To set c.env for testing, you...
Testing: Env
Source evidence: /Sources/honojs__hono/provenance.md Canonical citation: https://hono.dev/llms-full.txt#env
Summary
To set c.env for testing, you can pass it as the 3rd parameter to app.request. This is useful for mocking values like Cloudflare Workers Bindings: ```ts const MOCK_ENV =...
Content
To set c.env for testing, you can pass it as the 3rd parameter to app.request. This is useful for mocking values like Cloudflare Workers Bindings:
const MOCK_ENV = {
API_HOST: 'example.com',
DB: {
prepare: () => {
/* mocked D1 */
},
},
}
test('GET /posts', async () => {
const res = await app.request('/posts', {}, MOCK_ENV)
})
Metadata
{
"chunk_index": 0,
"citation": "https://hono.dev/llms-full.txt#env",
"coverage_role": "overview",
"qualified_title": "Hono / llms-full / Testing > Env",
"retrieved_at": "2026-07-02T05:51:01Z",
"section_index": 99,
"source_id": "/honojs/hono",
"source_type": "llms_full",
"target_label": "llms-full",
"title": "Testing: Env",
"upstream_url": "https://hono.dev/llms-full.txt",
"version": "2026"
}