Skip to content
Myr

index.ts

This file

Path

src/helper/testing/index.ts

27 lines · 980 bytes · TypeScript

Last changed by

Not known.

History of this file

Take it

The walk stopped after 200 commits: lines older than f0b094d point at it.

Merge commit from forkYusuke Wadabefore adoptionf0b094d

lines 1–27why, one step back
1/**
2 * @module3 * Testing Helper for Hono.4 */56import { hc } from '../../client'7import type { Client, ClientRequestOptions } from '../../client/types'8import type { ExecutionContext } from '../../context'9import type { Hono } from '../../hono'10import type { Schema } from '../../types'11import type { UnionToIntersection } from '../../utils/types'1213type ExtractEnv<T> = T extends Hono<infer E, Schema, string> ? E : never1415// eslint-disable-next-line @typescript-eslint/no-explicit-any16export const testClient = <T extends Hono<any, Schema, string>>(17 app: T,18 Env?: ExtractEnv<T>['Bindings'] | {},19 executionCtx?: ExecutionContext,20 options?: Omit<ClientRequestOptions, 'fetch'>21): UnionToIntersection<Client<T, 'http://localhost'>> => {22 const customFetch = (input: RequestInfo | URL, init?: RequestInit) => {23 return app.request(input, init, Env, executionCtx)24 }2526 return hc<typeof app, 'http://localhost'>('http://localhost', { ...options, fetch: customFetch })27}