
Studio Testing Strategy
OfficialFreeStreamline your testing process for Supabase Studio.
Free · Opens the source repo
What Studio Testing Strategy does
The Studio Testing Strategy skill provides a structured approach to writing and organizing tests for the Supabase Studio application. It emphasizes the importance of separating logic from React components into pure utility functions, which can then be tested independently. This method not only enhances testability but also promotes cleaner, more maintainable code. The skill outlines when to use different types of tests, including unit tests, component tests, and end-to-end (E2E) tests, ensuring that developers can make informed decisions about their testing strategies.
This skill is particularly useful for developers working on the Supabase Studio codebase, as it offers clear guidelines for writing tests, determining the necessity of tests for new features, and assessing existing test coverage. By following the outlined rules, developers can ensure that their code is robust, and that edge cases are accounted for. The skill also includes a decision tree to help developers choose the appropriate type of test based on the nature of the logic being implemented.
The testing strategy is categorized by priority, highlighting critical areas such as logic extraction and test coverage, as well as the appropriate use of component and E2E tests. This structured approach allows teams to maintain high standards of quality and reliability in their code, ultimately leading to a better user experience. The skill is designed for developers who want to improve their testing practices and ensure that their contributions to the Supabase Studio project are thoroughly vetted before deployment.
When to use it
Use this skill when developing new features for Supabase Studio or when reviewing existing test coverage.
When not to use it
This skill may not be suitable for projects outside of the Supabase Studio context or for teams not utilizing the outlined testing strategies.
What you can build with it
Writing New Tests
When adding new features to Supabase Studio, reference this skill to determine the appropriate tests needed.
Reviewing Test Coverage
Use the guidelines to assess whether existing tests adequately cover the logic and features of your application.
Extracting Logic for Testability
Follow the skill's recommendations to refactor complex logic into utility functions, making them easier to test.
How to install Studio Testing Strategy
View source1. Install with the skills CLI
npx skills add supabase/supabase/studio-testing --agent claude-code2. Or install it manually
Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.
Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs
Inside SKILL.md
Written by supabaseStudio 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.tsfiles 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 test
1. 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.tsnext to the component - Test:
tests/components/.../ComponentName.utils.test.tsmirroring 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 beforeEach
4. 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 |
|---|---|
| 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) |
Frequently asked questions about Studio Testing Strategy
Similar skills
Quality Playbook Generator
Run comprehensive quality audits on any codebase.
PR Draft Summary
Automate PR summary generation for openai-agents-python.
Final Release Review
Streamline your release candidate audits with ease.
Unit Test Vue Pinia
Efficiently write and review unit tests for Vue 3 applications.
Slang Shader Expert
Optimize and integrate Slang shaders with ease.
Telemetry Standards
Ensure consistent event tracking in Supabase Studio.
