The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.
TypeScript aialternativeauthdatabasedenoembeddingsexamplefirebasenextjsoauth2pgvectorpostgispostgrespostgresqlpostgrestrealtimesupabasevectorswebsockets
prettier
Rodrigo Mansueli Nunesb721065e1a2e
diff --git a/apps/docs/pages/guides/functions/unit-test.mdx b/apps/docs/pages/guides/functions/unit-test.mdxindex 1228a20f65a..9f6d26abcf8 100644--- a/apps/docs/pages/guides/functions/unit-test.mdx+++ b/apps/docs/pages/guides/functions/unit-test.mdx@@ -6,7 +6,7 @@ export const meta = {description: 'Writing Unit Tests for Edge Functions using Deno Test',}-Testing is an essential step in the development process to ensure the correctness and performance of your Edge Functions.+Testing is an essential step in the development process to ensure the correctness and performance of your Edge Functions.When creating test files for Edge Functions, it is recommended to place them in the `supabase/tests` directory and name the file by the function name followed by `-test.ts`. For example, `hello-world-test.ts`.@@ -81,16 +81,21 @@ Deno.test('Hello-world Function Test', testHelloWorld)This test case consists of two parts. The first part tests the client library and verifies that the database can be connected to and returns values from a table (`my_table`). The second part tests the edge function and checks if the received value matches the expected value. Here's a brief overview of the code:<Admonition type="note">-- We import various testing functions from the Deno standard library, including `assert`, `assertExists`, and `assertEquals`.-- We import the `createClient` and `SupabaseClient` classes from the `@supabase/supabase-js` library to interact with the Supabase client.-- We define the necessary configuration for the Supabase client, including the Supabase URL, API key, and authentication options.-- The `testClientCreation` function tests the creation of a Supabase client instance and queries the database for data from a table. It verifies that data is returned from the query.-- The `testHelloWorld` function tests the "Hello-world" Edge Function by invoking it using the Supabase client's `functions.invoke` method. It checks if the response message matches the expected greeting.-- We run the tests using the `deno test` function, providing a descriptive name for each test case and the corresponding test function.+ - We import various testing functions from the Deno standard library, including `assert`,+ `assertExists`, and `assertEquals`. - We import the `createClient` and `SupabaseClient` classes+ from the `@supabase/supabase-js` library to interact with the Supabase client. - We define the+ necessary configuration for the Supabase client, including the Supabase URL, API key, and+ authentication options. - The `testClientCreation` function tests the creation of a Supabase+ client instance and queries the database for data from a table. It verifies that data is returned+ from the query. - The `testHelloWorld` function tests the "Hello-world" Edge Function by invoking+ it using the Supabase client's `functions.invoke` method. It checks if the response message+ matches the expected greeting. - We run the tests using the `deno test` function, providing a+ descriptive name for each test case and the corresponding test function.</Admonition><Admonition type="important">-Please make sure to replace the placeholders (`supabaseUrl`, `supabaseKey`, `my_table`) with the actual values relevant to your Supabase setup.+ Please make sure to replace the placeholders (`supabaseUrl`, `supabaseKey`, `my_table`) with the+ actual values relevant to your Supabase setup.</Admonition>### Running Edge Functions Locally