apps/docs/content/guides/local-development/cli/testing-and-linting.mdx
The Supabase CLI provides a set of tools to help you test and lint your Postgres database and Edge` Functions.
The Supabase CLI provides Postgres linting using the supabase test db command.
supabase test db --help
Tests local database with pgTAP
Usage:
supabase test db [flags]
This is powered by the pgTAP extension. You can find a full guide to writing and running tests in the Testing your database section.
Our friends at Basejump have created a useful set of Database Test Helpers, with an accompanying blog post.
Use our GitHub Action to automate your database tests.
Edge Functions are powered by Deno, which provides a native set of testing tools. We extend this functionality in the Supabase CLI. You can find a detailed guide in the Edge Functions section.
The Supabase CLI uses Mailpit to capture emails sent from your local machine. This is useful for testing emails sent from Supabase Auth.
By default, Mailpit is available at localhost:54324 when you run supabase start. Open this URL in your browser to view the emails.
The "default" email provided by Supabase is only for development purposes. It is heavily restricted 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.
The Supabase CLI provides Postgres linting using the supabase db lint command:
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, which leverages the internal Postgres parser/evaluator so you see any errors that would occur at runtime. It provides the following features:
RETURN command)RETURN commands with your Postgres functionEXECUTE statements against SQL injection vulnerabilityCheck the Reference Docs for more information.