@trpc/server in a non-server environment Error in Azure CI

Im trying to add vitest unit tests for my trpc procedures. I followed some examples and on the local evn all works. Tests pass but in the Azure CI I get this error.
Error: You're trying to use @trpc/server in a non-server environment. This is not supported by default.
#19 7.732 ❯ initTRPCInner node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:808:23
#19 7.732 ❯ TRPCBuilder.create node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:782:33
#19 7.732 ❯ src/server/api/trpc.ts:32:56
#19 7.734 30| import { createTRPCConte***t } from './conte***t'
#19 7.734 31|
#19 7.734 32| const t = initTRPC.conte***t<typeof createTRPCConte***t>().create({
#19 7.734 | ^
#19 7.734 33| transformer: superjson,
#19 7.734 34| errorFormatter({ shape, ct*** }) {
Error: You're trying to use @trpc/server in a non-server environment. This is not supported by default.
#19 7.732 ❯ initTRPCInner node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:808:23
#19 7.732 ❯ TRPCBuilder.create node_modules/.pnpm/@trpc+server@10.8.1/node_modules/@trpc/server/dist/inde***.mjs:782:33
#19 7.732 ❯ src/server/api/trpc.ts:32:56
#19 7.734 30| import { createTRPCConte***t } from './conte***t'
#19 7.734 31|
#19 7.734 32| const t = initTRPC.conte***t<typeof createTRPCConte***t>().create({
#19 7.734 | ^
#19 7.734 33| transformer: superjson,
#19 7.734 34| errorFormatter({ shape, ct*** }) {
N
Nick435d ago
You've probably imported your Backend into the Frontend Make sure where you're importing the AppRouter you're doing import type { AppRouter } from 'backend' Or you just need to set up your tests project to include the Node environment, it may be browser by default
M
Mugetsu435d ago
mmm this might be it but why it works locally then
N
Nick435d ago
Sometimes the mode of tools changes when CI=1 is set in the environment. This would be a weird case of that though
M
Mugetsu435d ago
@Nick Lucas Thanks for the tip! You were right. I've changed default setting for vitest from environment: 'jsdom', to per file via comment and it worked ❤️
More Posts
How are people handling authorization?I noticed that with V10, any mentions of `trpc-shield` are gone from the documentation. Also, it onlVitest context router callerHi, Im trying to setup vitest to test trpc. I would like to have a trpc approuter caller to be accesWebSocket connection hangs after significant amount of data passed through the connection.Hey! I've been really enjoying using tRPC on my latest project, but have gotten stuck getting websoCannot read properties of undefined (reading 'data') of res.error.data, when trpc errors outHello everyone, I am using `@trpc/react-query` alongside `trpc` for express, and I am experiencing aIs there an example of a real world non trivial app?Something that includes type inference, nested fields, calculated fields, nested React components thHow to organise output types?I'm having a hard time trying to figure out what the best way to organise output types and I was wonExtending middlewareshttps://trpc.io/docs/middlewares#extending-middlewares Is this available?Calling a trpc endpoint inside of a trpc endpointHey all. I'm wondering how I am able to call these endpoints from within themselves? For example,Frozen input paramIs it possible to define a parameter on input schema (zod) that will have a hardcoded/frozen value wtype mismatch between tRPC return (in sveltekit) and defined typei've got this piece of code: ```ts read: async () => { const res = await trpc($page).getCards.querpre fetch serveral prodecures dynamicallyHello!. I'm developing a React Native app which needs an offline mode for some assets that the user procedure input contextIs it possible to accesss context in trpc procedure input validation? I have an aray of values in tIs it normal to separate resolvers from routers?Wondering if it's common and/or whether it's a good idea to attempt to separate procedures from the i have an infinite loop within my hook but apps works as expected.when i console log inside this hook, it repeats non-stop every few seconds, but my app is working as