supabase icon indicating copy to clipboard operation
supabase copied to clipboard

Testing Best Practices

Open philliphartin opened this issue 2 years ago • 0 comments

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! 🙏

philliphartin avatar Aug 30 '23 06:08 philliphartin