Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Testing strategy for Supabase Studio. Use when writing tests, deciding whether a change needs tests and which type, extracting logic from components into testable utility functions, or reviewing test coverage. Covers unit tests, component tests, and E2E test selection criteria.
.claude/skills/supabase-studio-testing/SKILL.md| Test case | Without → With | Effect | Δ tokens | Δ turns |
|---|---|---|---|---|
| case-01 | ✗→✓ | ▲ Improved | 78% | 0% |
| case-02 | ✗→✓ | ▲ Improved | 42% | 0% |
| case-03 | ✗→✓ | ▲ Improved | 55% | 0% |
| case-07 | ✗→✓ | ▲ Improved | 66% | 0% |
| case-08 | ✗→✓ | ▲ Improved | 40% | 0% |
How to write and structure tests for apps/studio/. The core principle: push logic out of React components into pure utility functions, then test those functions exhaustively. Only use component tests for complex UI interactions. Use E2E tests for features shared between self-hosted and platform.
Reference these guidelines when:
| Priority | Category | Impact | Prefix | | -------- | ---------------- | -------- | ---------- | | 1 | Logic Extraction | CRITICAL | testing- | | 2 | Test Coverage | CRITICAL | testing- | | 3 | Component Tests | HIGH | testing- | | 4 | E2E Tests | HIGH | testing- |
testing-extract-logic - Remove logic from components into .utils.ts filesas pure functions: args in, return out
testing-exhaustive-permutations - Test every permutation of utility functions:happy path, malformed input, empty values, edge cases
testing-component-tests-ui-only - Only write component tests for complex UIinteraction logic, not business logic
testing-e2e-shared-features - Write E2E tests for features used in bothself-hosted and platform; cover clicks AND keyboard shortcuts
Is the logic a pure transformation (parse, format, validate, compute)?
YES -> Extract to .utils.ts, write unit test with vitest
NO -> Does the feature involve complex UI interactions?
YES -> Is it used in both self-hosted and platform?
YES -> Write E2E test in e2e/studio/features/
NO -> Write component test with customRender
NO -> Can you extract the logic to make it pure?
YES -> Do that, then unit test it
NO -> Write a component testRemove as much logic from components as possible. Put it in co-located .utils.ts files as pure functions: arguments in, return value out.
File naming:
ComponentName.utils.ts next to the componenttests/components/.../ComponentName.utils.test.ts mirroring the source pathtsx// ❌ Logic buried in component — hard to test without rendering function TaxIdForm({ taxIdValue, taxIdName }: Props) { const handleSubmit = () => { const taxId = TAX_IDS.find((t) => t.name === taxIdName) let sanitized = taxIdValue if (taxId?.vatPrefix && !taxIdValue.startsWith(taxId.vatPrefix)) { sanitized = taxId.vatPrefix + taxIdValue } submitToApi(sanitized) } return <form onSubmit={handleSubmit}>...</form> } // ✅ Logic extracted to .utils.ts — trivially testable // TaxID.utils.ts export function sanitizeTaxIdValue({ value, name }: { value: string; name: string }): string { const taxId = TAX_IDS.find((t) => t.name === name) if (taxId?.vatPrefix && !value.startsWith(taxId.vatPrefix)) { return taxId.vatPrefix + value } return value } // TaxIdForm.tsx — thin shell const handleSubmit = () => { const sanitized = sanitizeTaxIdValue({ value: taxIdValue, name: taxIdName }) submitToApi(sanitized) }
Once logic is extracted, test exhaustively. Every code path needs a test:
ts// ❌ Only happy path test('parses a filter', () => { expect(formatFilterURLParams('id:gte:20')).toStrictEqual({ column: 'id', operator: 'gte', value: '20' }) }) // ✅ Every permutation test('parses valid filter', () => { ... }) test('handles timestamp with colons in value', () => { ... }) test('rejects malformed filter with missing parts', () => { ... }) test('rejects unrecognized operator', () => { ... }) test('allows empty filter value', () => { ... })
Only write component tests when there is complex UI interaction logic that cannot be captured by testing utility functions alone.
Valid reasons: conditional rendering from user interaction sequences, popover open/close with keyboard/mouse, multi-step form transitions.
Not valid: testing a calculation or transformation that happens to live in a component — extract to .utils.ts and unit test instead.
Studio component test conventions:
tsximport { screen } from '@testing-library/react' import { platformComponents as components } from 'api-types' import { HttpResponse } from 'msw' import { customRender } from '@/tests/lib/custom-render' import { addAPIMock } from '@/tests/lib/msw' type OrganizationResponse = components['schemas']['OrganizationResponse'] addAPIMock({ method: 'get', path: '/platform/organizations', response: () => HttpResponse.json<OrganizationResponse[]>([]), }) customRender(<MyComponent />) expect(await screen.findByText('No organizations')).toBeInTheDocument()
addAPIMock (MSW) — unhandled requests fail the test. Don't vi.mock('@/data/...'). Always pass the OpenAPI body type to HttpResponse.json<…>.customRender wraps the component in the providers Studio needs (React Query, router, etc.).studio-mock-api-tests skill.If a feature exists in both self-hosted and platform, create an E2E test. Cover mouse clicks AND keyboard shortcuts (Tab, Enter, Escape, Arrow keys).
Extract reusable interactions into e2e/studio/utils/*-helpers.ts. Use try/finally for resource cleanup. For E2E execution details, see the studio-e2e-tests skill.
| What | Where | | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | Util test examples | apps/studio/tests/components/Grid/Grid.utils.test.ts, apps/studio/tests/components/Billing/TaxID.utils.test.ts, apps/studio/tests/components/Editor/SpreadsheetImport.utils.test.ts | | Component test examples | apps/studio/tests/features/logs/LogsFilterPopover.test.tsx, apps/studio/tests/components/CopyButton.test.tsx | | E2E test example | e2e/studio/features/filter-bar.spec.ts | | E2E helpers pattern | e2e/studio/utils/filter-bar-helpers.ts | | Custom render | apps/studio/tests/lib/custom-render.tsx | | MSW mock setup | apps/studio/tests/lib/msw.ts (addAPIMock) | | Test README | apps/studio/tests/README.md | | Vitest config | apps/studio/vitest.config.ts | | Related skills | studio-e2e-tests (running E2E), vitest (API reference), vercel-composition-patterns (component architecture) |
| Case | Status | Duration (ms) | Turns | Tokens | Tool calls | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Without | With | Δ | Without | With | Δ | Without | With | Δ | Without | With | Δ | ||
case-01 | fail→pass | 18,094 | 17,925 | -1% | 1 | 1 | 0% | 2,933 | 5,212 | +78% | 0 | 0 | — |
case-02 | fail→pass | 23,768 | 17,529 | -26% | 1 | 1 | 0% | 3,780 | 5,351 | +42% | 0 | 0 | — |
case-03 | fail→pass | 16,632 | 13,481 | -19% | 1 | 1 | 0% | 2,718 | 4,222 | +55% | 0 | 0 | — |
case-04 | pass→pass | 19,178 | 16,959 | -12% | 1 | 1 | 0% | 3,445 | 5,250 | +52% | 0 | 0 | — |
case-05 | pass→pass | 20,083 | 16,959 | -16% | 1 | 1 | 0% | 3,066 | 4,561 | +49% | 0 | 0 | — |
case-06 | pass→pass | 19,707 | 13,759 | -30% | 1 | 1 | 0% | 3,872 | 4,337 | +12% | 0 | 0 | — |
case-07 | fail→pass | 10,480 | 5,618 | -46% | 1 | 1 | 0% | 1,842 | 3,050 | +66% | 0 | 0 | — |
case-08 | fail→pass | 16,209 | 10,360 | -36% | 1 | 1 | 0% | 2,747 | 3,840 | +40% | 0 | 0 | — |
case-09 | fail→pass | 13,746 | 6,004 | -56% | 1 | 1 | 0% | 2,205 | 3,042 | +38% | 0 | 0 | — |
case-10 | pass→pass | 14,329 | 4,909 | -66% | 1 | 1 | 0% | 2,212 | 2,743 | +24% | 0 | 0 | — |
case-11 | fail→pass | 14,065 | 19,514 | +39% | 1 | 1 | 0% | 2,049 | 3,817 | +86% | 0 | 0 | — |
case-12 | pass→pass | 13,448 | 4,088 | -70% | 1 | 1 | 0% | 2,246 | 2,491 | +11% | 0 | 0 | — |
case-13 | fail→pass | 14,281 | 4,111 | -71% | 1 | 1 | 0% | 2,292 | 2,719 | +19% | 0 | 0 | — |
case-14 | fail→pass | 14,866 | 3,056 | -79% | 1 | 1 | 0% | 1,594 | 2,371 | +49% | 0 | 0 | — |
case-15 | pass→pass | 23,169 | 9,767 | -58% | 1 | 1 | 0% | 1,794 | 3,715 | +107% | 0 | 0 | — |
case-16 | fail→pass | 11,981 | 5,346 | -55% | 1 | 1 | 0% | 1,520 | 2,658 | +75% | 0 | 0 | — |
case-17 | pass→pass | 132,294 | 3,659 | -97% | 1 | 1 | 0% | 1,734 | 2,489 | +44% | 0 | 0 | — |
case-18 | fail→pass | 11,833 | 3,076 | -74% | 1 | 1 | 0% | 1,927 | 2,367 | +23% | 0 | 0 | — |
case-19 | pass→pass | 16,347 | 8,338 | -49% | 1 | 1 | 0% | 2,395 | 2,912 | +22% | 0 | 0 | — |
case-20 | fail→pass | 12,601 | 11,828 | -6% | 1 | 1 | 0% | 2,407 | 4,378 | +82% | 0 | 0 | — |
case-21 | fail→pass | 8,013 | 2,598 | -68% | 1 | 1 | 0% | 1,357 | 2,298 | +69% | 0 | 0 | — |
case-22 | pass→pass | 16,248 | 10,216 | -37% | 1 | 1 | 0% | 2,619 | 3,838 | +47% | 0 | 0 | — |
case-23 | pass→pass | 9,126 | 5,659 | -38% | 1 | 1 | 0% | 1,406 | 2,696 | +92% | 0 | 0 | — |
DecimalAI ran this skill against gemini-3.6-flash twice over the same eval suite — once with the skill loaded and once without — and compared the two runs case by case. 23 cases were attempted. The headline lift of +57 percentage points is the difference between those two pass rates over the 23 comparable cases.
Without the skill loaded, the model failed this case. With it loaded, the same prompt on the same model passed. This is one improved case from the latest verified run; every case, including any that regressed, is in the table above.
Other measured skills in the registry, with their headline benchmark lift.