import { beforeAll, afterAll, beforeEach } from '@jest/globals'; import { PrismaClient } from '@shieldai/db'; import { BillingService } from '@shieldai/shared-billing'; import { EmailService, SMSService, PushService } from '@shieldai/shared-notifications'; // Global test setup beforeAll(async () => { // Initialize test database await import('./fixtures/test-db'); // Initialize services with test config process.env.STRIPE_API_KEY = 'sk_test_123'; process.env.STRIPE_WEBHOOK_SECRET = 'whsec_123'; process.env.RESEND_API_KEY = 're_123'; process.env.TWILIO_ACCOUNT_SID = 'AC123'; process.env.TWILIO_AUTH_TOKEN = 'token123'; process.env.TWILIO_MESSAGING_SERVICE_SID = 'MG123'; process.env.FCM_PROJECT_ID = 'test-project'; process.env.FCM_CLIENT_EMAIL = 'test@test-project.iam.gserviceaccount.com'; process.env.FCM_PRIVATE_KEY = '"-----BEGIN PRIVATE KEY-----\\ntest\\n-----END PRIVATE KEY-----\\n"'; process.env.APNS_KEY = 'apns_key'; process.env.APNS_KEY_ID = 'key_id'; process.env.APNS_TEAM_ID = 'team_id'; process.env.APNS_BUNDLE_ID = 'com.shieldai.app'; }); beforeEach(async () => { // Reset service state between tests const prisma = new PrismaClient(); await prisma.$transaction([ prisma.subscription.deleteMany(), prisma.notification.deleteMany(), prisma.spamFeedback.deleteMany(), ]); }); afterAll(async () => { // Cleanup const prisma = new PrismaClient(); await prisma.$disconnect(); });