From bf3bada7fd7420bc076bbc3671d7d11cb8a84d49 Mon Sep 17 00:00:00 2001 From: Charis <26616127+charislam@users.noreply.github.com> Date: Tue, 27 May 2025 10:00:21 -0400 Subject: [PATCH] test: run supabase locally during test (#35947) Alter the docs test script so it spins up Supabase locally. Will allow for end-to-end tests against the local DB. Also small alteration to one of the test files to silence an annoying (but intended) error. --- .github/workflows/docs-tests.yml | 1 + apps/docs/app/api/graphql/tests/searchDocs.test.ts | 7 ++++++- apps/docs/package.json | 3 ++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/docs-tests.yml b/.github/workflows/docs-tests.yml index 714df8489ec..dc029e56c5b 100644 --- a/.github/workflows/docs-tests.yml +++ b/.github/workflows/docs-tests.yml @@ -25,6 +25,7 @@ jobs: apps/docs examples packages + supabase - uses: pnpm/action-setup@v4 name: Install pnpm diff --git a/apps/docs/app/api/graphql/tests/searchDocs.test.ts b/apps/docs/app/api/graphql/tests/searchDocs.test.ts index 1d9d3c3d03c..3788f58697d 100644 --- a/apps/docs/app/api/graphql/tests/searchDocs.test.ts +++ b/apps/docs/app/api/graphql/tests/searchDocs.test.ts @@ -1,4 +1,4 @@ -import { afterAll, describe, expect, it, vi } from 'vitest' +import { afterAll, beforeAll, describe, expect, it, vi } from 'vitest' import { Result } from '~/features/helpers.fn' import { type OpenAIClientInterface } from '~/lib/openAi' import { ApiError } from '../../utils' @@ -45,7 +45,12 @@ vi.mock('~/lib/supabase', () => ({ })) describe('/api/graphql searchDocs', () => { + beforeAll(() => { + vi.spyOn(console, 'error').mockImplementation(() => {}) + }) + afterAll(() => { + vi.restoreAllMocks() vi.doUnmock('~/lib/openAi') vi.doUnmock('~/lib/supabase') }) diff --git a/apps/docs/package.json b/apps/docs/package.json index 36753e57541..4215dcb5c99 100644 --- a/apps/docs/package.json +++ b/apps/docs/package.json @@ -20,7 +20,8 @@ "pretypecheck": "pnpm run codegen:graphql", "typecheck": "tsc --noEmit", "pretest": "pnpm run codegen:examples", - "test": "vitest --exclude \"**/*.smoke.test.ts\"", + "test": "pnpm supabase start && pnpm run test:local && pnpm supabase stop", + "test:local": "vitest --exclude \"**/*.smoke.test.ts\"", "test:smoke": "pnpm run codegen:references && vitest -t \"prod smoke test\"", "embeddings": "tsx scripts/search/generate-embeddings.ts", "embeddings:refresh": "pnpm run embeddings --refresh",