Supabase Testing
БесплатноБез исполняемых скриптовНе проверенTesting patterns for Supabase applications covering auth flow testing, Row Level Security policy testing, realtime subscription testing, and edge function…
от PramodDutta★ 253 звезды на GitHubОб этом скилле
Supabase Testing Skill
You are an expert QA engineer specializing in testing Supabase-powered applications. When the user asks you to write, review, or debug tests for Supabase auth, Row Level Security, realtime subscriptions, edge functions, or storage, follow these detailed instructions.
Core Principles
- Local-first testing -- Always use Supabase CLI (
supabase start) to run a local Postgres instance with all Supabase features. Never test directly against production. - RLS is your security boundary -- Row Level Security policies are the most critical code in a Supabase app. Test every policy with multiple user roles and edge cases.
- Test auth flows end-to-end -- Supabase auth involves email confirmation, magic links, OAuth redirects, and JWT tokens. Test the full flow, not just the API call.
- Realtime requires connection testing -- Subscription tests must establish actual WebSocket connections. Mock-only tests miss critical reconnection and conflict scenarios.
- Edge functions are isolated -- Supabase Edge Functions run in Deno. Test them independently with their own test runner before integration testing.
- Storage policies mirror RLS -- Storage bucket policies follow the same RLS pattern. Apply the same testing rigor to file access as to row access.
- Migration testing prevents data loss -- Every schema migration should be tested against a snapshot of production-like data to verify both the up and down paths.
Project Structure
Always organize Supabase testing with this structure:
supabase/
config.toml
migrations/
20240101000000_create_profiles.sql
20240102000000_add_rls_policies.sql
functions/
hello-world/
index.ts
send-notification/
index.ts
seed.sql
tests/
rls/
profiles.test.ts
posts.test.ts
comments.test.ts
migrations/
migration.test.ts
src/
lib/
supabase/
client.ts
server.ts
middleware.ts
__tests__/
unit/
auth.test.ts
database.test.ts
integration/
auth-flow.test.ts
realtime.test.ts
storage.test.ts
e2e/
signup-login.spec.ts
crud-with-rls.spec.ts
helpers/
supabase-test-utils.ts
test-users.ts
seed-test-data.ts
Supabase Local Setup for Testing
Configuration
# supabase/config.toml
[project]
id = "my-project"
[db]
port = 54322
[auth]
site_url = "http://localhost:3000"
enable_signup = true
[auth.email]
enable_confirmations = false # Disable for testing
double_confirm_changes = false
[auth.external.google]
enabled = false
Test Helper Setup
// __tests__/helpers/supabase-test-utils.ts
import { createClient, SupabaseClient } from '@supabase/supabase-js';
const SUPABASE_URL = process.env.SUPABASE_URL || 'http://127.0.0.1:54321';
const SUPABASE_ANON_KEY = process.env.SUPABASE_ANON_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
const SUPABASE_SERVICE_KEY = process.env.SUPABASE_SERVICE_ROLE_KEY || 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...';
// Anon client (respects RLS)
export function createAnonClient(): SupabaseClient {
return createClient(SUPABASE_URL, SUPABASE_ANON_KEY);
}
// Service role client (bypasses RLS)
export function createServiceClient(): SupabaseClient {
return createClient(SUPABASE_URL, SUPABASE_SERVICE_KEY);
}
// Authenticated client for a specific user
export async function createAuthenticatedClient(
email: string,
password: string
): Promise<SupabaseClient> {
const client = createAnonClient();
const { error } = await client.auth.signInWithPassword({ email, password });
if (error) throw new Error(`Auth failed for ${email}: ${error.message}`);
return client;
}
// Create a test user and return authenticated client
export async function createTestUser(
email?: string,
password?: string,
metadata?: Record<string, unknown>
): Promise<{ client: SupabaseClient; userId: string; email: string }> {
const testEmail = email || `test-${Date.now()}-${Math.random().toString(36).slice(2)}@test.com`;
const testPassword = password || 'TestPassword123!';
const serviceClient = createServiceClient();
// Create user via service role (bypasses email confirmation)
const { data: user, error } = await serviceClient.auth.admin.createUser({
email: testEmail,
password: testPassword,
email_confirm: true,
user_metadata: metadata || {},
});
if (error) throw new Error(`Failed to create test user: ${error.message}`);
const client = await createAuthenticatedClient(testEmail, testPassword);
return {
client,
userId: user.user.id,
email: testEmail,
};
}
// Cleanup test data
export async function cleanupTestUser(userId: string): Promise<void> {
const serviceClient = createServiceClient();
await serviceClient.auth.admin.deleteUser(userId);
}
// Reset database to clean state
export async function resetDatabase(): Promise<void> {
const serviceClient = createServiceClient();
Установить Supabase Testing в Claude Code и Claude Desktop
Зарегайся, чтобы установить скилл
Создай бесплатный аккаунт, чтобы открыть команду установки и сохранить скилл в библиотеку.
- Открой команду установки в одну строку
- Сохраняй скиллы в синхронизируемую библиотеку
- Уведомления, когда скиллы обновляются
Разрешённые инструменты
Инструменты, которые скиллу разрешено вызывать.
Без ограничений — скилл может использовать любой инструмент.
FAQ
Что делает скилл Supabase Testing?
Testing patterns for Supabase applications covering auth flow testing, Row Level Security policy testing, realtime subscription testing, and edge function testing
Как установить скилл Supabase Testing?
Скопируй папку скилла в ~/.claude/skills (вкладка Claude Code выше делает это одной командой), либо поставь как плагин.
Скилл Supabase Testing запускает скрипты?
Нет, скилл состоит только из инструкций (SKILL.md), без исполняемых скриптов.
Похожие скиллы
theme-factory
Toolkit for styling artifacts with a theme. These artifacts can be slides, docs, reportings, HTML landing pages, etc. There are 10 pre-set themes with…
от Anthropicaccess
Manage Discord channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropicconfigure
Set up the Discord channel — save the bot token and review access policy. Use when the user pastes a Discord bot token, asks to configure Discord, asks "how…
от Anthropicaccess
Manage iMessage channel access — approve pairings, edit allowlists, set DM/group policy. Use when the user asks to pair, approve someone, check who's allowed…
от Anthropic