Vitest Test can't load serverRuntimeConfig
Hey im currently running into this error:
``
This is my userid.test.ts:
`
vitest.config.ts
``
So how to correctly mock the serverRuntimeConfig?
1 Reply
Judging your file naming, it looks like you are testing behaviour in your
user
scope. Your error is occuring in .../router/distribution-report.ts
which may not be related to your test suite.
This code may only get executed because you load your whole appRouter
in your user test. You could prevent that by just importing the regarding sub-router (userRouter?) there.
This does not answer the actual question, but might help you with your current situation.
Maybe it's a generally bad idea to access Next's config data there, but I have no hint on what to do instead. Maybe someone else might have another idea on that.