import { defineConfig } from 'cypress';
import { readFileSync } from 'fs';
import { resolve } from 'path';

export default defineConfig({
  chromeWebSecurity: false,
  e2e: {
    baseUrl: 'http://localhost:8080',
    specPattern: 'cypress/e2e/frontend/**/*.{cy,spec}.{js,ts}',
    supportFile: 'cypress/support/e2e.ts',
    setupNodeEvents(on, config) {
      on('task', {
        getSchema() {
          return readFileSync(resolve(__dirname, '../server/schema.graphql'), 'utf8');
        },
      });
    },
  },
  videoUploadOnPasses: false,
  reporter: 'junit',
  reporterOptions: {
    mochaFile: 'cypress/test-reports/frontend/cypress-results-[hash].xml',
    toConsole: true,
  },
  projectId: 'msk-fe',
  retries: {
    runMode: 3,
  },
});
