import { join } from 'node:path'
import react from '@vitejs/plugin-react'
import { defineConfig } from 'vitest/config'

const gateResultsDir = process.env.CI_GATE_RESULTS_DIR

export default defineConfig({
  plugins: [react()],
  test: {
    environment: 'jsdom',
    include: ['src/**/*.test.{ts,tsx}'],
    setupFiles: ['./src/test-setup.ts'],
    reporters: gateResultsDir
      ? ['default', ['json', { outputFile: join(gateResultsDir, 'raw', 'workspace-apps-web.json') }]]
      : ['default'],
  },
})
