/supabase:e2e-test-scenariosfrom supabase
End-to-end testing scenarios for Supabase covering database workflows, auth flows, AI features (pgvector), realtime subscriptions, and production readiness validation.
Ships in supabase. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them; scripts run unread.
This skill provides comprehensive end-to-end testing capabilities for Supabase applications, covering database operations, authentication flows, AI features (pgvector), realtime subscriptions, and production readiness validation.
Initialize test environment:
bash scripts/setup-test-env.sh
This creates:
Configure test database:
SUPABASE_TEST_URL and SUPABASE_TEST_ANON_KEYInstall dependencies:
npm install --save-dev @supabase/supabase-js jest @types/jest
# or
pnpm add -D @supabase/supabase-js vitest
Test complete database operations from schema to queries:
Run database E2E tests:
bash scripts/test-database-workflow.sh
This validates:
Use pgTAP for SQL-level tests:
# Run all database tests
supabase test db
# Run specific test file
supabase test db --file tests/database/users.test.sql
Test schema migrations:
# Test migration up/down
supabase db reset --linked
supabase db push
# Verify schema state
bash scripts/validate-schema.sh
Test complete auth workflows end-to-end:
Run authentication E2E tests:
bash scripts/test-auth-workflow.sh
This validates:
Test RLS with authenticated users:
// See templates/auth-tests.ts for complete examples
test('authenticated users see only their data', async () => {
const { data, error } = await supabase
.from('private_notes')
.select('*');
expect(data).toHaveLength(userNoteCount);
expect(data.every(note => note.user_id === userId)).toBe(true);
});
Test session persistence:
# Run session validation tests
npm test -- auth-session.test.ts
Test vector search and semantic operations:
Run AI features E2E tests:
bash scripts/test-ai-features.sh
This validates:
Test vector search accuracy:
// See templates/vector-search-tests.ts
test('semantic search returns relevant results', async () => {
const queryEmbedding = await generateEmbedding('machine learning');
const { data } = await supabase.rpc('match_documents', {
query_embedding: queryEmbedding
match_threshold: 0.7
match_count: 5
});
expect(data.length).toBeGreaterThan(0);
expect(data[0].similarity).toBeGreaterThan(0.7);
});
Test embedding operations:
# Validate embedding pipeline
npm test -- embedding-workflow.test.ts
Performance benchmarking:
# Run performance tests
bash scripts/benchmark-vector-search.sh [TABLE_NAME] [VECTOR_DIM]
Test realtime subscriptions and presence:
Run realtime E2E tests:
bash scripts/test-realtime-workflow.sh
This validates:
Test database change subscriptions:
// See templates/realtime-tests.ts
test('receives real-time updates on insert', async () => {
const updates = [];
const subscription = supabase
.channel('test-channel')
.on('postgres_changes'
{ event: 'INSERT', schema: 'public', table: 'messages' }
(payload) => updates.push(payload)
)
.subscribe();
await supabase.from('messages').insert({ content: 'test' });
await waitFor(() => expect(updates).toHaveLength(1));
});
Test presence and broadcast:
# Run presence tests
npm test -- presence.test.ts
Run full workflow tests simulating real user scenarios:
Execute complete E2E test suite:
bash scripts/run-e2e-tests.sh
This runs:
Run test scenarios in parallel:
# Run all test suites
npm test -- --maxWorkers=4
# Run specific workflow
npm test -- workflows/document-rag.test.ts
Generate test reports:
# Generate coverage report
npm test -- --coverage
# Generate HTML report
npm test -- --coverage --coverageReporters=html
Setup automated testing in CI/CD pipelines:
Use GitHub Actions template:
# Copy CI config to your repo
cp templates/ci-config.yml .github/workflows/supabase-tests.yml
Configure test secrets:
SUPABASE_TEST_URL to GitHub secretsSUPABASE_TEST_ANON_KEY to GitHub secretsSUPABASE_TEST_SERVICE_ROLE_KEY for admin testsRun tests on pull requests:
Clean up test resources after testing:
Run cleanup script:
bash scripts/cleanup-test-resources.sh
This removes:
Reset test database:
# Reset to clean state
supabase db reset --linked
# Or use migration-based reset
bash scripts/reset-test-db.sh
// Load test fixtures
const testData = await loadFixtures('users', 'posts', 'comments');
// Seed database
await seedDatabase(testData);
// Cleanup after tests
afterAll(async () => {
await cleanupFixtures();
});
// Create test users with factories
const user = await createTestUser({
email: '[email protected]'
metadata: { role: 'admin' }
});
// Create related data
const posts = await createTestPosts(user.id, 5);
test_ prefix for test datatest('authenticated user CRUD operations', async () => {
// 1. Sign up user
const { user } = await supabase.auth.signUp({
email: '[email protected]'
password: 'test123'
});
// 2. Create resource
const { data } = await supabase
.from('notes')
.insert({ content: 'test note' })
.select()
.single();
// 3. Verify ownership
expect(data.user_id).toBe(user.id);
// 4. Update resource
await supabase
.from('notes')
.update({ content: 'updated' })
.eq('id', data.id);
// 5. Delete resource
await supabase.from('notes').delete().eq('id', data.id);
});
test('document RAG workflow', async () => {
// 1. Upload document
const doc = await uploadDocument('test.pdf');
// 2. Generate embeddings
const chunks = await chunkDocument(doc);
const embeddings = await generateEmbeddings(chunks);
// 3. Store in database
await supabase.from('document_chunks').insert(
chunks.map((chunk, i) => ({
content: chunk
embedding: embeddings[i]
document_id: doc.id
}))
);
// 4. Perform semantic search
const query = 'What is the main topic?';
const queryEmbedding = await generateEmbedding(query);
const { data } = await supabase.rpc('match_documents', {
query_embedding: queryEmbedding
match_count: 5
});
// 5. Verify results
expect(data.length).toBeGreaterThan(0);
expect(data[0].similarity).toBeGreaterThan(0.7);
});
test('multi-user realtime chat', async () => {
// 1. Create two users
const user1 = await createTestUser();
const user2 = await createTestUser();
// 2. Subscribe to messages
const user1Messages = [];
const user2Messages = [];
const sub1 = await subscribeToMessages(user1, user1Messages);
const sub2 = await subscribeToMessages(user2, user2Messages);
// 3. User 1 sends message
await sendMessage(user1, 'Hello from user 1');
// 4. Verify both users receive it
await waitFor(() => {
expect(user1Messages).toHaveLength(1);
expect(user2Messages).toHaveLength(1);
});
// 5. Cleanup subscriptions
await sub1.unsubscribe();
await sub2.unsubscribe();
});
--maxWorkers flagScripts:
scripts/setup-test-env.sh - Initialize test environmentscripts/run-e2e-tests.sh - Execute complete test suitescripts/test-database-workflow.sh - Database E2E testsscripts/test-auth-workflow.sh - Authentication E2E testsscripts/test-ai-features.sh - Vector search E2E testsscripts/test-realtime-workflow.sh - Realtime E2E testsscripts/cleanup-test-resources.sh - Clean up test datascripts/validate-schema.sh - Validate database schemascripts/benchmark-vector-search.sh - Performance benchmarksscripts/reset-test-db.sh - Reset test databaseTemplates:
templates/test-suite-template.ts - Jest/Vitest boilerplatetemplates/database-tests.ts - Database operation teststemplates/auth-tests.ts - Authentication flow teststemplates/vector-search-tests.ts - pgvector teststemplates/realtime-tests.ts - Realtime subscription teststemplates/ci-config.yml - GitHub Actions CI/CDtemplates/jest.config.js - Jest configurationtemplates/vitest.config.ts - Vitest configurationExamples:
examples/complete-test-workflow.md - Full E2E testing guideexamples/ci-cd-integration.md - CI/CD setup guideexamples/test-data-strategies.md - Test data managementexamples/performance-benchmarks.md - Performance testingexamples/mocking-strategies.md - Mocking external servicesPlugin: supabase Version: 1.0.0 Last Updated: 2025-10-26
QUICK_START.md (opens in a new tab)README.md (opens in a new tab)SKILL_SUMMARY.md (opens in a new tab)examples/ci-cd-integration.md (opens in a new tab)examples/complete-test-workflow.md (opens in a new tab)examples/test-data-strategies.md (opens in a new tab)scripts/cleanup-test-resources.sh (opens in a new tab)scripts/run-e2e-tests.sh (opens in a new tab)scripts/setup-test-env.sh (opens in a new tab)scripts/test-ai-features.sh (opens in a new tab)scripts/test-auth-workflow.sh (opens in a new tab)scripts/test-realtime-workflow.sh (opens in a new tab)templates/auth-tests.ts (opens in a new tab)templates/ci-config.yml (opens in a new tab)templates/realtime-tests.ts (opens in a new tab)templates/test-suite-template.ts (opens in a new tab)templates/vector-search-tests.ts (opens in a new tab)What SKILL.md sets; muted values are Claude Code's defaults
Three short reads, in order
e2e-testing, supabase, auth-testing, database-testing, ai-testing, pgvector
npx claudepluginhub vanman2024/ai-dev-marketplace --plugin supabase8 skills in this plugin
/agentic-platform-schemaAgentic Platform Contract tables for AI agent applications - runs, events, artifacts, and tool calls tracking. Use when building AI agent backends that need structured run/event storage./auth-configsConfigure Supabase authentication providers (OAuth, JWT, email). Use when setting up authentication, configuring OAuth providers (Google/GitHub/Discord), implementing auth flows, configuring JWT settings, or when user mentions Supabase auth, social login, authentication setup, or auth configuration./pgvector-setupConfigure pgvector extension for vector search in Supabase - includes embedding storage, HNSW/IVFFlat indexes, hybrid search setup, and AI-optimized query patterns. Use when setting up vector search, building RAG systems, configuring semantic search, creating embedding storage, or when user mentions pgvector, vector database, embeddings, semantic search, or hybrid search./rls-templatesRow Level Security policy templates for Supabase - multi-tenant patterns, user isolation, role-based access, and secure-by-default configurations. Use when securing Supabase tables, implementing RLS policies, building multi-tenant AI apps, protecting user data, creating chat/RAG systems, or when user mentions row level security, RLS, Supabase security, tenant isolation, or data access policies./rls-test-patternsRLS policy testing patterns for Supabase - automated test cases for Row Level Security enforcement, user isolation verification, multi-tenant security, and comprehensive security audit scripts. Use when testing RLS policies, validating user isolation, auditing Supabase security, verifying tenant isolation, testing row level security, running security tests, or when user mentions RLS testing, security validation, policy testing, or data leak prevention./schema-patternsProduction-ready database schema patterns for AI applications including chat/conversation schemas, RAG document storage with pgvector, multi-tenant organization models, user management, and AI usage tracking. Use when building AI applications, creating database schemas, setting up chat systems, implementing RAG, designing multi-tenant databases, or when user mentions supabase schemas, chat database, RAG storage, pgvector, embeddings, conversation history, or AI application database.Other plugins' skills for the same job