testing setup

This commit is contained in:
2025-08-29 14:19:38 +02:00
parent e74b30e04c
commit 869cc07fdd
46 changed files with 6710 additions and 1460 deletions

View File

@@ -0,0 +1,26 @@
import { createTRPCProxyClient, httpBatchLink } from '@trpc/client'
import { fetchRequestHandler } from '@trpc/server/adapters/fetch'
import { trpcRouter, type TrpcRouter } from '~/server/routers/_app'
// This simulates the server without HTTP
function serverHandler(path: string, req: Request) {
return fetchRequestHandler({
endpoint: '/api/trpc',
router: trpcRouter,
req,
createContext: () => ({}),
})
}
export function createTestTrpcClient() {
return createTRPCProxyClient<TrpcRouter>({
links: [
httpBatchLink({
url: 'http://localhost/api/trpc',
fetch: (input, init) => {
return serverHandler(input as string, new Request(input as string, init))
},
}),
],
})
}