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:docsOr 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:uiThere 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 scorersbraintrust-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.tsfor Studio. - DOM mocking:
jsdomandjsdom-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-checksThe 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.ymldocs-tests.yml,docs-tests-smoke.ymlui-tests.yml,ui-patterns-tests.ymlpg-meta-tests.yml,ai-tests.ymlprettier.yml,typecheck.yml,validate-pr.ymlself-host-tests-smoke.yml
Built by Factory AutoWiki from public repository content. It is a generated preview for codebase exploration, not source-maintained documentation.