test: fix typescript issues related to tests#22
Conversation
…istency - Replaced `createCaller` implementation with a `t.createCallerFactory` tied to `appRouter`. - Adjusted test cases to use `caller.health` instead of directly invoking `.ping()`. - Modified `tsconfig.json` to set `module` as `esnext` and `moduleResolution` as `Bundler`. - Updated test scripts in `package.json` to set `ENCRYPTION_SECRET`. - Added `@jest/globals` to `devDependencies` and synced `pnpm-lock.yaml`.
WalkthroughThe PR refactors the test Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes
Possibly related PRs
Poem
Pre-merge checks and finishing touches❌ Failed checks (1 inconclusive)
✅ Passed checks (2 passed)
✨ Finishing touches
🧪 Generate unit tests (beta)
📜 Recent review detailsConfiguration used: CodeRabbit UI Review profile: CHILL Plan: Pro ⛔ Files ignored due to path filters (1)
📒 Files selected for processing (6)
🧰 Additional context used🧬 Code graph analysis (2)packages/api/src/__tests__/utils/createCaller.ts (1)
packages/api/src/__tests__/routers/health.test.ts (2)
🔇 Additional comments (7)
Comment |
There was a problem hiding this comment.
Pull Request Overview
This PR updates the testing infrastructure for the API package, migrating to tRPC v11's createCallerFactory API and modernizing the test setup. The changes include adding Jest globals as an explicit dependency, updating TypeScript compiler options for module resolution, and refactoring the test utilities to use a more streamlined caller pattern.
Key Changes:
- Refactored
createCallertest utility to use tRPC v11'screateCallerFactoryAPI, binding it to the fullappRouter - Added
@jest/globalsv30.2.0 as an explicit devDependency - Updated test scripts to remove
NODE_OPTIONS='--experimental-vm-modules'and addENCRYPTION_SECRETenvironment variable - Modified TypeScript config to use
esnextmodule andBundlermoduleResolution
Reviewed Changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
pnpm-lock.yaml |
Adds lockfile entry for @jest/globals v30.2.0 dependency |
packages/api/package.json |
Adds @jest/globals dependency and updates test scripts to set ENCRYPTION_SECRET instead of NODE_OPTIONS |
packages/api/tsconfig.json |
Overrides base config with esnext module and Bundler moduleResolution, reformats include/exclude arrays |
packages/api/src/__tests__/utils/createCaller.ts |
Refactors from generic router caller to appRouter-specific caller factory |
packages/api/src/__tests__/utils/index.ts |
Changes from named export to wildcard export for createCaller |
packages/api/src/__tests__/routers/health.test.ts |
Updates test calls to use new caller API pattern (caller.health.ping instead of caller.ping) |
packages/api/src/__tests__/routers/trpc.test.ts |
Adds signal: undefined parameter to procedure test calls and removes trailing whitespace |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
createCallerimplementation with at.createCallerFactorytied toappRouter.caller.healthinstead of directly invoking.ping().tsconfig.jsonto setmoduleasesnextandmoduleResolutionasBundler.package.jsonto setENCRYPTION_SECRET.@jest/globalstodevDependenciesand syncedpnpm-lock.yaml.Summary by CodeRabbit