supabase
supabase copied to clipboard
Testing Best Practices
Hi all,
I’ve gone all in on Nuxt and Supabase. I’m in the process of porting my existing projects over, but I’m stuck on one key element: Testing.
I’ve created an example repo with a single Nuxt API endpoint to demonstrate the types of tests I would like to cover. https://github.com/pjhartin/nuxt-supabase-testing-playground
Specifically, I’m struggling to test features that rely on authentication. I would greatly appreciate some guidance on best practices and whether these types of tests are common.
I want to achieve the following:
- Ability to generate a user for the purposes of a test
- Ability to authenticate as that user within the lifecycle of a test
- e.g. Perform an API request as User X
- e.g. View a page as User Y
- Make assertions against the database
I am currently running Supabase locally for development and testing purposes. Is this considered bad practice? Should I be mocking everything instead? Please take a look at the example repo I shared above.
Any advice here would be greatly appreciated! 🙏