You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
tRPC's core repository uses powerful internal helpers to spin up an in-process server and typed client for integration tests, but application developers have no stable, public way to do this. Introduce an official testing harness so users can write router-level integration tests without depending on internal test utilities.
Describe the solution you'd like to see
Implement a dedicated testing package that exposes a single high-level helper to create a fully wired tRPC server and client pair for a given router. Ensure the helper infers router types, accepts optional context and link configuration, and actually routes calls through HTTP or WebSocket adapters. Preserve existing public APIs and behavior when the helper is not used. Errors thrown by procedures must surface as standard tRPC client errors on the caller side.
Describe alternate solutions
Expose a new public module '@trpc/testing' exporting a function named 'testServerAndClient' used only in tests.
Additional information
No response
👨👧👦 Contributing
🙋♂️ Yes, I'd be down to file a PR implementing this feature!
i'd ship a public @trpc/testing helper that spins up a real server plus client, with createcaller still available for unit tests. same headers/context factory as createhttpserver, therefore procedure tests can hit the full link stack.
should this live in packages/testing or under @trpc/server/testing? and is vitest the only runner to support first?
🤖 In v12, the supported way to test a router is in process: createRouterClient(router, { ctx }) gives a typed client with the same shape as the real one, and localLink runs calls through the client's other links without a server, so procedure errors reach the test exactly as a client sees them. The docs point to examples/saas-api, which tests its API both ways. A real-server TestServer layer exists in @trpc12/trpc/internal/testing, but it's semi-public with no compatibility promise. https://v12.trpc.io/v12/docs/server/server-side-calls#testing. v12 isn't released yet and there's no ETA.
Activity
coderabbitai commentedon Dec 2, 2025
Related Issues
Suggested Issue Assignees
Actions
ℹ️ Note: Issue enrichment is currently in early access.
Disable automatic issue enrichment
To disable automatic issue enrichment, add the following to your
.coderabbit.yaml:ArjunCodess commentedon Sep 19, 2026
hi, i'd like to work on this.
i'd ship a public @trpc/testing helper that spins up a real server plus client, with createcaller still available for unit tests. same headers/context factory as createhttpserver, therefore procedure tests can hit the full link stack.
should this live in packages/testing or under @trpc/server/testing? and is vitest the only runner to support first?
KATT commentedon Nov 2, 2026
🤖 In v12, the supported way to test a router is in process:
createRouterClient(router, { ctx })gives a typed client with the same shape as the real one, andlocalLinkruns calls through the client's other links without a server, so procedure errors reach the test exactly as a client sees them. The docs point toexamples/saas-api, which tests its API both ways. A real-serverTestServerlayer exists in@trpc12/trpc/internal/testing, but it's semi-public with no compatibility promise. https://v12.trpc.io/v12/docs/server/server-side-calls#testing. v12 isn't released yet and there's no ETA.