vanman2024 avatar

e2e-test-scenarios

End-to-end testing scenarios for Supabase - complete workflow tests from project creation to AI feat

提供方 vanman2024|开源

E2E Test Scenarios Skill

Complete end-to-end testing framework for Supabase applications, covering database operations, authentication flows, AI features (pgvector), realtime subscriptions, and full integration testing.

Quick Start

1. Setup Test Environment

bash scripts/setup-test-env.sh

This creates:

  • .env.test configuration file
  • Test directory structure
  • Sample test files
  • Jest/Vitest configuration

2. Configure Test Credentials

Edit .env.test with your test project credentials:

SUPABASE_TEST_URL=http://localhost:54321
SUPABASE_TEST_ANON_KEY=your-test-anon-key
SUPABASE_TEST_SERVICE_ROLE_KEY=your-test-service-role-key
DATABASE_URL=postgresql://postgres:postgres@localhost:54322/postgres

3. Run Tests

# Run complete test suite
bash scripts/run-e2e-tests.sh

# Run specific test suite
bash scripts/run-e2e-tests.sh --suite auth

# Run with coverage
bash scripts/run-e2e-tests.sh --coverage

Test Suites

Database Tests (pgTAP)

Tests schema, migrations, RLS policies, and database functions.

# Run database tests
bash scripts/test-database-workflow.sh
supabase test db

Authentication Tests

Tests signup, login, sessions, password reset, and RLS enforcement.

# Run auth tests
bash scripts/test-auth-workflow.sh
npm test -- tests/auth

Vector/AI Features Tests

Tests pgvector extension, embedding operations, and semantic search.

# Run AI feature tests
bash scripts/test-ai-features.sh
npm test -- tests/vector

Realtime Tests

Tests database change subscriptions, broadcast, and presence.

# Run realtime tests
bash scripts/test-realtime-workflow.sh
npm test -- tests/realtime

Integration Tests

Tests complete user workflows from signup to data operations.

# Run integration tests
npm test -- tests/integration

Scripts

ScriptPurpose
setup-test-env.shInitialize test environment
run-e2e-tests.shExecute complete test suite
test-auth-workflow.shTest authentication flows
test-ai-features.shTest pgvector and embeddings
test-realtime-workflow.shTest realtime features
cleanup-test-resources.shClean up test data

Templates

TemplatePurpose
test-suite-template.tsJest/Vitest test boilerplate
auth-tests.tsAuthentication flow tests
vector-search-tests.tspgvector and semantic search tests
realtime-tests.tsRealtime subscription tests
ci-config.ymlGitHub Actions CI/CD configuration

Examples

ExampleDescription
complete-test-workflow.mdStep-by-step E2E testing guide
ci-cd-integration.mdCI/CD setup for multiple platforms
test-data-strategies.mdTest data management patterns

CI/CD Integration

GitHub Actions

# Copy CI configuration
cp templates/ci-config.yml .github/workflows/supabase-tests.yml

# Configure secrets in GitHub repository settings
# - SUPABASE_TEST_URL
# - SUPABASE_TEST_ANON_KEY
# - SUPABASE_TEST_SERVICE_ROLE_KEY

Tests run automatically on:

  • Push to main/develop branches
  • Pull requests
  • Manual workflow dispatch

Test Coverage

The test suite covers:

  • ✅ Database schema validation
  • ✅ Migration testing
  • ✅ RLS policy enforcement
  • ✅ User authentication flows
  • ✅ Session management
  • ✅ Password reset
  • ✅ Vector embedding storage
  • ✅ Semantic similarity search
  • ✅ HNSW/IVFFlat indexes
  • ✅ Realtime subscriptions
  • ✅ Broadcast messaging
  • ✅ Presence tracking
  • ✅ Complete user workflows

Performance Benchmarks

Target performance metrics:

  • Simple queries: < 50ms
  • Vector similarity search: < 100ms
  • Hybrid search: < 200ms
  • Realtime message delivery: < 100ms
  • Auth operations: < 500ms

Cleanup

Clean up test resources after testing:

# Standard cleanup
bash scripts/cleanup-test-resources.sh

# Full database reset
bash scripts/cleanup-test-resources.sh --full

Troubleshooting

Supabase Not Running

supabase status  # Check status
supabase start   # Start local instance

Connection Errors

Verify .env.test credentials and Supabase is accessible.

Test Timeouts

Increase timeout in .env.test:

TEST_TIMEOUT=60000

RLS Policy Failures

Use service role key for admin operations or adjust RLS policies for testing.

Best Practices

  1. Use Local Supabase for development and CI/CD
  2. Dedicated Test Project for production testing
  3. Clean Up After Tests to maintain test isolation
  4. Run Tests in Parallel for faster execution
  5. Monitor Coverage - maintain > 70% coverage
  6. Version Test Data - use fixtures for consistency

Resources

Support

For issues or questions:

  1. Check the examples/ directory for detailed guides
  2. Review script comments for implementation details
  3. Consult Supabase documentation
  4. Check GitHub Actions logs for CI failures

Plugin: supabase Version: 1.0.0 Skill: e2e-test-scenarios

e2e-test-scenarios - AI Agent Skill for Claude Code & Cursor | Agent Skills