Help: Testing Nuxt API Routes Using serverSupabaseServiceRole and serverSupabaseUser with Vitest #503
cubinet-code
started this conversation in
General
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
I’m currently writing tests for Nuxt server API routes using Vitest, and I’m having trouble mocking the Supabase utilities provided by #supabase/server — specifically serverSupabaseUser(event) and serverSupabaseServiceRole(event).
Despite searching extensively, I haven’t found any clear examples or official documentation on how to test Nuxt routes that depend on these functions. The serverSupabaseUser is used to get the authenticated user, and serverSupabaseServiceRole gives a service client for queries. Both are deeply integrated into route logic, so I need a way to mock or stub them to write proper unit tests.
Example route I’m testing
Here’s a simplified version of the route handler (in server/api/accounts/index.ts):
What I’ve tried
What I need help with
⸻
Thanks in advance! 🙏
If I find a solution, I’ll be sure to post it here for others.
Beta Was this translation helpful? Give feedback.
All reactions