Component testing with Vitest and server actions.
Unanswered
Beauceron posted this in #help-forum
BeauceronOP
I'm running into some issues with setting up vitest to do component testing. Over all I'm using a similar setup as can be seen here: https://nextjs.org/docs/app/building-your-application/testing/vitest
The big difference is that my component uses tanstack query that makes fetch requests using server actions.
My question is essentially, how would I mock this? What would be the best course of action?
Bonus question, my server action uses an env to determine what the url it should use for the api call is and I'm getting the following error in vitest:
The big difference is that my component uses tanstack query that makes fetch requests using server actions.
My question is essentially, how would I mock this? What would be the best course of action?
Bonus question, my server action uses an env to determine what the url it should use for the api call is and I'm getting the following error in vitest:
Error: :x: Attempted to access a server-side environment variable on the client