You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// tests/integration/api/habit.api.test.tsdescribe('Habit API',()=>{describe('POST /api/habits',()=>{it('should create habit via API')it('should integrate with gamification')it('should log activity')})describe('POST /api/habits/:id/complete',()=>{it('should update both frontend and backend')it('should sync gamification state')})})
Database Integration Tests
User-Gamification Integration
// tests/integration/database/user-gamification.test.tsdescribe('User-Gamification DB Integration',()=>{it('should update XP across related tables')it('should maintain data consistency')it('should handle concurrent updates')})
Frontend-Backend Integration
State Synchronization
// tests/integration/frontend-backend/state-sync.test.tsdescribe('Frontend-Backend State Sync',()=>{it('should sync XP changes')it('should handle real-time updates')it('should manage offline scenarios')})
🌐 End-to-End Testing
E2E Test Scenarios
Habit Creation Flow
// tests/e2e/habit-creation.e2e.test.tsdescribe('Habit Creation E2E',()=>{it('should create habit from UI to database',async()=>{// 1. Navigate to habits page// 2. Click create button// 3. Fill form// 4. Submit// 5. Verify in database// 6. Verify in UI})})
Gamification Flow
// tests/e2e/gamification-flow.e2e.test.tsdescribe('Gamification E2E',()=>{it('should award XP and update UI',async()=>{// 1. Complete habit// 2. Verify XP increase// 3. Verify level advancement// 4. Verify badge awarding})})
User Journey Tests
New User Onboarding
// tests/e2e/user-onboarding.e2e.test.tsdescribe('New User Onboarding',()=>{it('should guide new user through first habit',async()=>{// 1. Register// 2. Create first habit// 3. Complete habit// 4. See XP/level changes// 5. Explore dashboard})})
Power User Journey
// tests/e2e/power-user.e2e.test.tsdescribe('Power User Journey',()=>{it('should handle advanced user interactions',async()=>{// Multiple habits// Goal completion// Analytics exploration// Badge achievements})})
🛠️ Test Utilities & Setup
Test Environment Setup
Database Setup
// tests/setup/database.tsexportconstsetupTestDatabase=async()=>{// Create test database// Run migrations// Seed initial data}exportconstteardownTestDatabase=async()=>{// Clean up test data// Close connections}
// Good: Specific and descriptivedescribe('HabitService.completeHabit',()=>{it('should award XP when habit is completed for the first time',()=>{// test implementation})it('should not award XP for already completed habit',()=>{// test implementation})})// Bad: Too vaguedescribe('Habit Service',()=>{it('should work',()=>{// test implementation})})