Open-Source Wikis

/

Supabase

/

How to contribute

/

Testing

supabase/supabase

Testing

The repo uses Vitest for unit / component tests, Playwright for end-to-end coverage of Studio, and Braintrust for AI eval workflows.

Test runners

Runner Used by Config
Vitest apps/studio, apps/docs, apps/www, packages/ui, packages/ui-patterns, packages/ai-commands, packages/pg-meta, packages/common vitest.config.ts per package.
Playwright e2e/studio e2e/studio workspace.
Braintrust apps/studio/evals/ evals/assistant.eval.ts.
GitHub Actions All of the above + lint / typecheck / prettier .github/workflows/*.yml.

Unit / component tests

Files are co-located with the source under the same package (*.test.ts(x)). Run a single package's suite with one of the top-level scripts:

pnpm test:studio
pnpm test:studio:watch
pnpm test:ui
pnpm test:ui-patterns
pnpm test:docs

Or run all of them via turbo run test. Studio uses @testing-library/react, @testing-library/user-event, and msw (apps/studio/__mocks__/) for HTTP mocking. The Vitest setup file lives at apps/studio/vitest.config.ts (and per-package equivalents).

Coverage is collected via @vitest/coverage-v8. Studio's pnpm test:studio runs with --coverage by default and reports go to apps/studio/coverage/.

End-to-end (Studio)

End-to-end tests live in e2e/studio/. They drive a real local Supabase stack:

# 1. Start a Supabase CLI stack and seed it for e2e
pnpm e2e:setup:cli

# 2. Run Playwright headlessly
pnpm e2e

# Or interactively
pnpm e2e:ui

There are two CI variants (e2e:setup:selfhosted and e2e:setup:platform) that build Studio in production mode against the docker stack or a pre-built platform; both are wired through studio-e2e-test.yml.

Smoke tests

docs-tests-smoke.yml and self-host-tests-smoke.yml are reduced suites that run on every PR to catch obvious breakage before the heavier jobs.

AI evals (Studio)

apps/studio/evals/ defines Braintrust evals for the in-product Assistant and SQL helpers. Common commands:

pnpm --filter studio evals:setup    # copies wasm fixtures
pnpm --filter studio evals:run      # runs locally without sending logs
pnpm --filter studio evals:upload   # uploads to braintrust
pnpm --filter studio scorers:deploy # deploys online scorers

braintrust-evals.yml runs evals on PRs that touch the Assistant. Preview scorers are deployed by braintrust-preview-scorers-deploy.yml and torn down by braintrust-preview-scorers-cleanup.yml.

Mocking

  • HTTP mocks: MSW (msw), declared per package under __mocks__/handlers.ts for Studio.
  • DOM mocking: jsdom and jsdom-testing-mocks.
  • Postgres parsing: libpg-query (wasm) is used both at runtime and in tests for SQL parsing.

Lint & typecheck as tests

pnpm lint and pnpm typecheck are first-class checks — they run in CI alongside Vitest. Studio has a "ratchet" workflow that prevents specific eslint rule counts from increasing:

pnpm --filter studio lint:ratchet
pnpm --filter studio lint:ratchet:type-checks

The ratchet rules live in apps/studio/scripts/ratchet-eslint-rules.ts. See Tooling for details.

Test layout cross-reference

Subsystem Where the tests live
Studio components apps/studio/components/**/__tests__/* and *.test.tsx next to the source.
Studio data hooks Some hooks have error-patterns.test.ts, handleError.test.ts, etc. directly under apps/studio/data/.
Docs middleware apps/docs/middleware.test.ts (and per-feature tests under features/).
pg-meta packages/pg-meta/test/ plus inline tests beside generators.
ai-commands packages/ai-commands/test/.
ui / ui-patterns packages/ui/src/**/*.test.tsx, packages/ui-patterns/src/**/*.test.tsx.
Studio e2e e2e/studio/.

CI roll-up

Key workflows:

  • studio-unit-tests.yml, studio-e2e-test.yml, studio-master-alert.yml
  • docs-tests.yml, docs-tests-smoke.yml
  • ui-tests.yml, ui-patterns-tests.yml
  • pg-meta-tests.yml, ai-tests.yml
  • prettier.yml, typecheck.yml, validate-pr.yml
  • self-host-tests-smoke.yml

Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.

Testing – Supabase wiki | Factory