CodeVetter · Repo Unpack · Testing signals
trpc/trpc
Unit and integration tests are Vitest projects rooted at every packages/* package, with jsdom, globals, Istanbul coverage, and two CI retries. The heaviest behavioral coverage is packages/tests/server (adapters, batching, streaming, websockets, regressions) plus colocated tests in server, client, and react-query. Playwright smoke tests live in selected examples and run in a GitHub Actions matrix that is allowed to fail. OpenAPI fixture drift fails the unit job. App-dir, upgrade, vendor, www, and examples are excluded from coverage.
- Root test script is vitest. vitest.shared.ts sets environment jsdom, globals, setupFiles packages/tests/suppressActWarnings.ts, coverage provider istanbul including **/src/**, restoreMocks, execArgv --expose-gc, and retry 2 when CI is set.
- Coverage excludes www, examples, packages/next/src/app-dir, packages/server/src/adapters/next-app-dir, packages/upgrade/src, and vendor. codecov.yml sets project target auto with a 1% threshold, turns patch status off, ignores deprecated, form-data, app-dir, openapi cli.ts, and openapi test routers, and disables PR comments.
- packages/tests is the integration package described in CONTRIBUTING. Its server suite includes batching.test.ts, streaming.test.ts, websockets.test.ts, middlewares.test.ts, caller.test.ts, adapters/, and a regression/ directory. React act warnings are muted in CI via MUTE_REACT_ACT_WARNINGS=1.
- @trpc/react-query colocates dozens of hook tests under packages/react-query/test, including useQuery, useMutation, useInfiniteQuery, useSubscription, suspense variants, ssr/ssg, formData, and a regression/ folder. @trpc/tanstack-react-query tests options proxies under packages/tanstack-react-query/test.
- The unit-test CI job runs pnpm test --coverage and then fails if git status shows changes under packages/openapi/test/routers, telling contributors to run pnpm -C packages/openapi codegen. Codecov upload uses codecov-action@v6 and only passes CODECOV_TOKEN for non-fork PRs.
- Playwright is the e2e runner for examples that have playwright.config.ts. examples/minimal-react/test/smoke.test.ts loads / and waits for text=tRPC user with a 35s timeout. The e2e job runs, per example, test-dev, build, typecheck, and test-start via turbo, after copying .env.example to .env.
- The e2e matrix covers .experimental/next-app-dir, diagnostics-big-router, internal-types-export, ssg, cloudflare-workers, express-minimal, express-server, fastify-server, minimal-react, next-formdata, next-minimal-starter, next-prisma-starter, next-prisma-todomvc, next-prisma-websockets-starter, openapi-codegen, soa, standalone-server, vercel-edge-runtime, and nuxt. next-sse-chat is commented out. The job sets continue-on-error true.
- E2E Postgres is a GitHub service container with POSTGRES_HOST_AUTH_METHOD trust and user postgres. NEXTAUTH_SECRET is set to the literal supersecret in that job's env. Separate jobs e2e-deno (deno-deploy) and e2e-bun exist; both are also PR-only.
- Build and typecheck jobs run only on pull_request, not on push. The test job runs on both. Concurrency cancels in-progress runs for the same ref. Turbo remote cache uses secrets TURBO_TOKEN and vars TURBO_TEAM.
- examples/next-prisma-starter has both a Vitest test at src/server/routers/post.test.ts and Playwright at playwright/smoke.test.ts. Its CI path is included in the e2e matrix, so the example is part of the PR gate even though example sources are excluded from Istanbul coverage.
- Server package colocates tests such as procedureBuilder.test.ts, router.test.ts, initTRPC.test.ts, sse.test.ts, and adapters/node-http/incomingMessageToRequest.test.ts, including a case titled POST with body and maxBodySize. Client colocates createChain.test.ts, dedupeLink.test.ts, splitLink.test.ts, and localLink.test.ts.
- @trpc/upgrade tests live in packages/upgrade/test with fixture TSX files and transforms.test.ts, but upgrade/src is excluded from coverage, so the CLI's git and package-manager side effects are not in the Codecov gate.