import { execSync } from 'child_process'

async function globalSetup() {
  console.log('Running database seed before E2E tests...')
  try {
    execSync('npx prisma db seed', {
      stdio: 'inherit',
      env: process.env,
    })
    console.log('Database seed completed successfully')
  } catch (error) {
    console.error('Warning: Database seed failed. Tests may fail if seed data is missing.')
    console.error('Make sure Docker Compose is running and the database is accessible.')
  }
}

export default globalSetup
