Need Help with Vitest Login and Authorization Token using Supabase

Hello everyone!

I'm currently working on a project where I need to implement automated testing using Vitest. The challenge I'm facing is with the login process and retrieving the authorization token using Supabase. I've been trying to figure out the best way to integrate these two, but I'm stuck at a certain point.

Here's what I've done so far:

I've set up the basic testing environment with Vitest.
I have my Supabase project and database ready.
But, I'm not sure how to:

Perform the login in a test environment and get the user's authorization token.
Use this token for subsequent API requests in my tests.
I would really appreciate if someone could guide me or provide some example code on how to achieve this. Any tips on best practices for handling authentication in testing environments would also be super helpful!

Thanks in advance for your help!
Was this page helpful?