Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

more docs

Copple1a3f1bd89042
diff --git a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
index 2e8e357987c..765aef663dc 100644
--- a/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
+++ b/apps/docs/components/Navigation/NavigationMenu/NavigationMenu.constants.ts
@@ -1013,8 +1013,8 @@ export const supabase_cli: NavMenuConstant = {
url: '/guides/cli/seeding-your-database',
},
{
- name: 'Testing emails locally',
- url: '/guides/cli/testing-emails',
+ name: 'Testing and linting',
+ url: '/guides/cli/testing-and-linting',
},
],
},
@@ -1026,6 +1026,14 @@ export const supabase_cli: NavMenuConstant = {
name: 'Generate types from your database',
url: '/guides/cli/github-action/generating-types',
},
+ {
+ name: 'Automated testing',
+ url: '/guides/cli/github-action/testing',
+ },
+ {
+ name: 'Backup your database',
+ url: '/guides/cli/github-action/backups',
+ },
],
},
],
diff --git a/apps/docs/pages/guides/cli/github-action/[slug].tsx b/apps/docs/pages/guides/cli/github-action/[slug].tsx
index 181f3acb409..1e3934c265a 100644
--- a/apps/docs/pages/guides/cli/github-action/[slug].tsx
+++ b/apps/docs/pages/guides/cli/github-action/[slug].tsx
@@ -24,13 +24,31 @@ const pageMap = [
{
slug: 'generating-types',
meta: {
- title: 'Generate types from your database',
+ title: 'Generate types using GitHub Actions',
description: 'End-to-end type safety across client, server, and database.',
subtitle: 'End-to-end type safety across client, server, and database.',
tocVideo: 'VSNgAIObBdw',
},
remoteFile: 'generating-types.md',
},
+ {
+ slug: 'testing',
+ meta: {
+ title: 'Automated testing using GitHub Actions',
+ description: 'Run your tests when you or your team make changes.',
+ subtitle: 'Run your tests when you or your team make changes.',
+ },
+ remoteFile: 'testing.md',
+ },
+ {
+ slug: 'backups',
+ meta: {
+ title: 'Automated backups using GitHub Actions',
+ description: 'Backup your database on a regular basis.',
+ subtitle: 'Backup your database on a regular basis.',
+ },
+ remoteFile: 'backups.md',
+ },
]
interface ActionDocsProps {
diff --git a/apps/docs/pages/guides/cli/testing-and-linting.mdx b/apps/docs/pages/guides/cli/testing-and-linting.mdx
new file mode 100644
index 00000000000..8c297cdf244
--- /dev/null
+++ b/apps/docs/pages/guides/cli/testing-and-linting.mdx
@@ -0,0 +1,80 @@
+import Layout from '~/layouts/DefaultGuideLayout'
+
+export const meta = {
+ id: 'testing-emails-locally',
+ title: 'Testing emails locally',
+ description: 'Testing emails for Supabase Auth on your local machine.',
+ subtitle: 'Testing emails for Supabase Auth on your local machine.',
+}
+
+## Testing your database
+
+The Supabase CLI provides Postgres liniting using the `supabase test db` command.
+
+{/* prettier-ignore */}
+```markdown
+supabase test db --help
+Tests local database with pgTAP
+
+Usage:
+ supabase test db [flags]
+```
+
+This is powered by the [pgTAP](https://supabase.com/docs/guides/database/extensions/pgtap) extension. You can find a full guide to writing an running tests in the [Testing your database](/docs/guides/database/testing) section.
+
+### Test helpers
+
+Our friends at [Basejump](https://usebasejump.com/) have created a useful set of Database [Test Helpers](https://github.com/usebasejump/supabase-test-helpers), with an accompanying [blog post](https://usebasejump.com/blog/testing-on-supabase-with-pgtap).
+
+### Running database tests in CI
+
+Use our GitHub Action to [automate your database tests](docs/guides/cli/github-action/testing#testing-your-database).
+
+## Testing your Edge Functions
+
+Edge Functions are powered by Deno, which provides a [native set of testing tools](https://deno.land/[email protected]/basics/testing). We extend this functionality in the Supabase CLI. You can find a detailed guide in the [Edge Functions section](/docs/guides/functions/unit-test).
+
+## Testing Auth emails
+
+The Supabase CLI uses [Inbucket](https://github.com/inbucket/inbucket) to capture emails sent from your local machine. This is useful for testing emails sent from Supabase Auth.
+
+### Accessing Inbucket
+
+By default, Inbucket is available at [localhost:54324](http://localhost:54324) when you run `supabase start`. Simply open this URL in your browser to view the emails.
+
+### Going into Production
+
+The "default" email provided by Supabase is only for development purposes. It is [heavily restricted](/docs/guides/platform/going-into-prod#auth-rate-limits) to ensure that it is not used for spam. Before going into production, you must configure your own email provider. This is as simple as enabling a new SMTP credentials in your [project settings](https://supabase.com/dashboard/project/_/settings/auth).
+
+## Linting your database
+
+The Supabase CLI provides Postgres liniting using the `supabase db lint` command:
+
+{/* prettier-ignore */}
+```markdown
+supabase db lint --help
+Checks local database for typing error
+
+Usage:
+ supabase db lint [flags]
+
+Flags:
+ --level [ warning | error ] Error level to emit. (default warning)
+ --linked Lints the linked project for schema errors.
+ -s, --schema strings List of schema to include. (default all)
+```
+
+This is powered by [plpgsql_check](https://github.com/okbob/plpgsql_check), which leverages the internal Postgres parser/evaluator so you see any errors that would occur at runtime. It provides the following features:
+
+- validates you are using the correct types for function parameters
+- identifies unused variables and function arguments
+- detection of dead code (any code after an `RETURN` command)
+- detection of missing `RETURN` commands with your Postgres function
+- identifies unwanted hidden casts, which can be a performance issue
+- checks `EXECUTE` statements agaist SQL injection vulnerability
+
+Check the Reference Docs for [more information](/docs/reference/cli/supabase-db-lint).
+
+export const Page = ({ children }) => <Layout meta={meta} children={children} />
+
+export default Page
diff --git a/apps/docs/pages/guides/cli/testing-emails.mdx b/apps/docs/pages/guides/cli/testing-emails.mdx
deleted file mode 100644
index f9e3cce6706..00000000000
--- a/apps/docs/pages/guides/cli/testing-emails.mdx
+++ /dev/null
@@ -1,24 +0,0 @@
-import Layout from '~/layouts/DefaultGuideLayout'
-
-export const meta = {
- id: 'testing-emails-locally',
- title: 'Testing emails locally',
- description: 'Testing emails for Supabase Auth on your local machine.',
- subtitle: 'Testing emails for Supabase Auth on your local machine.',
-}
-
-The Supabase CLI uses [Inbucket](https://github.com/inbucket/inbucket) to capture emails sent from your local machine. This is useful for testing emails sent from Supabase Auth.
-
-## Accessing Inbucket
-
-By default, Inbucket is available at [localhost:54324](http://localhost:54324) when you run `supabase start`. Simply open this URL in your browser to view the emails.
-
-## Going into Production
-
-The "default" email provided by Supabase is only for development purposes. It is [heavily restricted](/docs/guides/platform/going-into-prod#auth-rate-limits) to ensure that it is not used for spam.
-
-Before you go into production, you must configure your own email provider. This is as simple as enabling a new SMTP credentials in your [project settings](https://supabase.com/dashboard/project/_/settings/auth).
-
-export const Page = ({ children }) => <Layout meta={meta} children={children} />
-
-export default Page
diff --git a/apps/docs/pages/guides/database/extensions/pgtap.mdx b/apps/docs/pages/guides/database/extensions/pgtap.mdx
index 42d4521687e..991d15097b5 100644
--- a/apps/docs/pages/guides/database/extensions/pgtap.mdx
+++ b/apps/docs/pages/guides/database/extensions/pgtap.mdx
@@ -72,8 +72,8 @@ API:
begin;
select plan( 2 );
-select has_column( 'profiles', 'id' ); # test that the "id" column exists in the "profiles" table
-select col_is_pk( 'profiles', 'id' ); # test that the "id" column is a primary key
+select has_column( 'profiles', 'id' ); -- test that the "id" column exists in the "profiles" table
+select col_is_pk( 'profiles', 'id' ); -- test that the "id" column is a primary key
select * from finish();
rollback;
@@ -94,8 +94,8 @@ select policies_are(
'public',
'profiles',
ARRAY [
- 'Profiles are public', # Test that there is a policy called "Profiles are public" on the "profiles" table.
- 'Profiles can only be updated by the owner' # Test that there is a policy called "Profiles can only be updated by the owner" on the "profiles" table.
+ 'Profiles are public', -- Test that there is a policy called "Profiles are public" on the "profiles" table.
+ 'Profiles can only be updated by the owner' -- Test that there is a policy called "Profiles can only be updated by the owner" on the "profiles" table.
]
);