End-to-end testing scenarios for Supabase - complete workflow tests from project creation to AI features, validation scripts, and comprehensive test suites. Use when testing Supabase integrations, validating AI workflows, running E2E tests, verifying production readiness, or when user mentions Supabase testing, E2E tests, integration testing, pgvector testing, auth testing, or test automation.
Limited to specific tools
Additional assets for this skill
This skill is limited to using the following tools:
QUICK_START.mdREADME.mdSKILL_SUMMARY.mdexamples/ci-cd-integration.mdexamples/complete-test-workflow.mdexamples/test-data-strategies.mdscripts/cleanup-test-resources.shscripts/run-e2e-tests.shscripts/setup-test-env.shscripts/test-ai-features.shscripts/test-auth-workflow.shscripts/test-realtime-workflow.shtemplates/auth-tests.tstemplates/ci-config.ymltemplates/realtime-tests.tstemplates/test-suite-template.tstemplates/vector-search-tests.tsThis 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: 'test@example.com'
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: 'test@example.com'
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