From 6f9b470da3d3c9d05d3c7d95195b5c2fe1a08677 Mon Sep 17 00:00:00 2001 From: Vojtech Novak Date: Mon, 1 Jul 2024 21:25:57 +0200 Subject: [PATCH] docs: document testing with higher-level tools (#26924) * docs: document testing with higher-level tools * Update apps/docs/content/guides/database/testing.mdx --------- Co-authored-by: Charis <26616127+charislam@users.noreply.github.com> --- apps/docs/content/guides/database/testing.mdx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/apps/docs/content/guides/database/testing.mdx b/apps/docs/content/guides/database/testing.mdx index f3d7f5e75d8..dc2df74ec55 100644 --- a/apps/docs/content/guides/database/testing.mdx +++ b/apps/docs/content/guides/database/testing.mdx @@ -4,6 +4,20 @@ title: 'Testing Your Database' description: 'Test your database schema, tables, functions, and policies.' --- +To ensure that queries return the expected data, RLS policies are correctly applied and etc., we encourage you to write automated tests. There are essentially two approaches to testing: + +- Firstly, you can write tests that interface with a Supabase client instance (same way you use Supabase client in your application code) in the programming language(s) you use in your application and using your favorite testing framework. + +- Secondly, you can test through the Supabase CLI, which is a more low-level approach where you write tests in SQL. + +# Testing through the Supabase client + +A good starting point are the tests written for the Supabase client itself. For example, [here](https://github.com/supabase/tests/tree/main/integration) are the tests for the Supabase JS client written with TypeScript and Jest. + +Keep in mind that the tests (which you'll likely integrate into your CI) need to run with the same DB setup that you're running locally. That means you need to make all changes to the database exclusively through migrations (not manually). + +# Testing using the Supabase CLI + You can use the Supabase CLI to test your database. The minimum required version of the CLI is [v1.11.4](https://github.com/supabase/cli/releases). To get started: - [Install the Supabase CLI](/docs/guides/cli) on your local machine