Automated testing using GitHub Actions
Run your tests when you or your team make changes.
Automated testing
You can use the Supabase CLI to run automated tests.
Testing your database#
After you have created unit tests for your database, you can use the GitHub Action to run the tests.
Inside your repository, create a new file inside the .github/workflows
folder called database-tests.yml
. Copy this snippet inside the file, and the action will run whenever a new PR is created:
_14name: 'database-tests'_14on:_14 pull_request:_14_14jobs:_14 build:_14 runs-on: ubuntu-latest_14 steps:_14 - uses: actions/checkout@v3_14 - uses: supabase/setup-cli@v1_14 with:_14 version: 1.11.4_14 - run: supabase db start_14 - run: supabase test db
Testing your Edge Functions#
After you have created unit tests for your Edge Functions, you can use the GitHub Action to run the tests.
Inside your repository, create a new file inside the .github/workflows
folder called functions-tests.yml
. Copy this snippet inside the file, and the action will run whenever a new PR is created:
_15name: 'functions-tests'_15on:_15 pull_request:_15_15jobs:_15 build:_15 runs-on: ubuntu-latest_15 steps:_15 - uses: actions/checkout@v3_15 - uses: supabase/setup-cli@v1_15 with:_15 version: 1.11.4_15 - run: supabase start_15 - run: supabase functions serve_15 - run: deno test --allow-all deno-test.ts --env-file .env.local
More resources#
- Learn more about the pgTAP extension for database testing.
- Official pgTAP Documentation: pgtap.org