Skip to content

feat: Official tRPC Testing Harness Package #7030

Open

Description

@StarJnrDev

Describe the feature you'd like to request

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!

Activity

  1. coderabbitai commented on Dec 2, 2025

    @coderabbitai
    Contributor

    Related Issues

    Suggested Issue Assignees

    • rhinodavid

    Actions

    • 📝 Generate an implementation plan for this issue

    ℹ️ Note: Issue enrichment is currently in early access.

    Disable automatic issue enrichment

    To disable automatic issue enrichment, add the following to your .coderabbit.yaml:

    issue_enrichment:
      auto_enrich:
        enabled: false
  2. ArjunCodess commented on Sep 19, 2026

    @ArjunCodess

    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?

  3. KATT commented on Nov 2, 2026

    @KATT
    Member

    🤖 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.

  4. added
    next-major/definite
    on Nov 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    next-major/definite

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions