/studio-testing
Testing strategy for Supabase Studio. Use when writing tests, deciding
$ npx -y skills add supabase/supabase --skill studio-testing --agent claude-codeHow it fires
How this skill gets triggered: by you, by Claude, or both.
- Fires itselfAuto-invocation. Claude auto-loads it when your prompt matches the work.Auto-invocation is when the right skill fires by itself at the right moment, driven by a FLOW.md router and a hook, instead of you invoking it by name. It is the difference between a skill being installed and a skill actually getting used.Read the full definition →
- You can call itInvoke it directly when you want it.
- Slash command
/studio-testing
Context preview
The summary Claude sees to decide when to auto-load this skill.
Testing strategy for Supabase Studio. Use when writing tests, deciding
SKILL.md
studio-testing.SKILL.mdname: studio-testing
description: 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.
Studio Testing Strategy
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.
When to Apply
Reference these guidelines when:
- Writing new tests for Studio code
- Deciding which type of test to write (unit, component, E2E)
- Extracting logic from a component to make it testable
- Reviewing whether test coverage is sufficient
- Adding a new feature that needs tests
Rule Categories by Priority
| Priority | Category | Impact | Prefix | | -------- | ---------------- | -------- | ---------- | | 1 | Logic Extraction | CRITICAL | `testing-` | | 2 | Test Coverage | CRITICAL | `testing-` | | 3 | Component Tests | HIGH | `testing-` | | 4 | E2E Tests | HIGH | `testing-` |
Quick Reference
1. Logic Extraction (CRITICAL)
- `testing-extract-logic` - Remove logic from components into `.utils.ts` files
as pure functions: args in, return out
2. Test Coverage (CRITICAL)
- `testing-exhaustive-permutations` - Test every permutation of utility functions:
happy path, malformed input, empty values, edge cases
3. Component Tests (HIGH)
- `testing-component-tests-ui-only` - Only write component tests for complex UI
interaction logic, not business logic
4. E2E Tests (HIGH)
- `testing-e2e-shared-features` - Write E2E tests for features used in both
self-hosted and platform; cover clicks AND keyboard shortcuts
Decision Tree: Which Test Type?
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 test1. Extract Logic Into Utility Files (CRITICAL)
Remove 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:**
- Utility: `ComponentName.utils.ts` next to the component
- Test: `tests/components/.../ComponentName.utils.test.ts` mirroring the source path
// ❌ 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)
}2. Test Every Permutation (CRITICAL)
Once logic is extracted, test exhaustively. Every code path needs a test:
- Valid inputs (happy path for each branch)
- Invalid / malformed inputs
- Empty values, null values, missing fields
- Edge cases (timestamps with colons, special characters, boundary values)
// ❌ 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', () => { ... })3. Component Tests for Complex UI Only (HIGH)
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
import { fireEvent } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { customRender } from 'tests/lib/custom-render' // always use customRender, not raw render
import { addAPIMock } from 'tests/lib/msw' // API mocking in beforeEach4. E2E Tests for Shared Features (HIGH)
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.
Codebase References
| What | Where
Read more
name: studio-testing description: 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.
Studio Testing Strategy
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.
When to Apply
Reference these guidelines when:
- Writing new tests for Studio code
- Deciding which type of test to write (unit, component, E2E)
- Extracting logic from a component to make it testable
- Reviewing whether test coverage is sufficient
- Adding a new feature that needs tests
Rule Categories by Priority
| Priority | Category | Impact | Prefix | | -------- | ---------------- | -------- | ---------- | | 1 | Logic Extraction | CRITICAL | `testing-` | | 2 | Test Coverage | CRITICAL | `testing-` | | 3 | Component Tests | HIGH | `testing-` | | 4 | E2E Tests | HIGH | `testing-` |
Quick Reference
1. Logic Extraction (CRITICAL)
- `testing-extract-logic` - Remove logic from components into `.utils.ts` files
as pure functions: args in, return out
2. Test Coverage (CRITICAL)
- `testing-exhaustive-permutations` - Test every permutation of utility functions:
happy path, malformed input, empty values, edge cases
3. Component Tests (HIGH)
- `testing-component-tests-ui-only` - Only write component tests for complex UI
interaction logic, not business logic
4. E2E Tests (HIGH)
- `testing-e2e-shared-features` - Write E2E tests for features used in both
self-hosted and platform; cover clicks AND keyboard shortcuts
Decision Tree: Which Test Type?
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 test1. Extract Logic Into Utility Files (CRITICAL)
Remove 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:**
- Utility: `ComponentName.utils.ts` next to the component
- Test: `tests/components/.../ComponentName.utils.test.ts` mirroring the source path
// ❌ 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)
}2. Test Every Permutation (CRITICAL)
Once logic is extracted, test exhaustively. Every code path needs a test:
- Valid inputs (happy path for each branch)
- Invalid / malformed inputs
- Empty values, null values, missing fields
- Edge cases (timestamps with colons, special characters, boundary values)
// ❌ 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', () => { ... })3. Component Tests for Complex UI Only (HIGH)
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
import { fireEvent } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { customRender } from 'tests/lib/custom-render' // always use customRender, not raw render
import { addAPIMock } from 'tests/lib/msw' // API mocking in beforeEach4. E2E Tests for Shared Features (HIGH)
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.
Codebase References
| What | Where
Supabase is the Postgres development platform. We're building the features of Firebase using enterprise-grade open source tools. [x] Hosted Postgres Database. Docs [x] Authentication and Authorization. Docs [x] Auto-generated APIs. [x] REST. Docs [x] GraphQL.
Repo: supabase/supabase
Other skills on supabase.
- /clickhouse-logs-queries
Write, review, and migrate Supabase logs queries against the ClickHouse-backed `logs` table (the `logs.all.otel` analytics endpoint). Use this whenever a task involves Logs Explorer SQL, the `log_attributes` map, querying a log `source` (edge_logs, postgres_logs, auth_logs,
Open skill - /copywriting
Write or audit UI copy (buttons, labels, empty states, error messages, tooltips, form text) anywhere in the monorepo. Load it before shipping or reviewing any user-facing text — including when copy is incidental to the task, like a new feature that adds buttons, toasts, dialogs,
Open skill - /dev-toolbar-review
Safety rules for the dev toolbar, PostHog client, and feature flags. Use
Open skill - /docs-content
Write, edit, organize, and review Supabase content anywhere in apps/docs — guides, explainers, tutorials, troubleshooting entries, reference docs, and partials. Use for MDX/TOML authoring, frontmatter, navigation, terminology, links, code samples, content listings, and docs
Open skill - /react-hook-form
Correct React Hook Form usage anywhere in the monorepo — data flow, subscriptions,
Open skill - /safe-sql-execution
Use whenever code will build, return, fetch, or execute SQL that runs against a user's real Postgres database — even when the request reads like an ordinary feature or bug fix and never says "security," "injection," or "SafeSqlFragment." This covers: writing or editing any
Open skill

