import type { PlaywrightTestConfig } from '@playwright/test' import type { WorkerConfigOptions } from './src/fixtures/config-options.js' import { defineConfig, devices } from '@playwright/test' import { fileURLToPath } from 'url' import * as path from 'path' import directus_config from './docker/directus-config.js' const __filename = fileURLToPath(import.meta.url) const __dirname = path.dirname(__filename) const testDir = './src' const playwrightDir = path.join(__dirname, '.playwright') const outputDir = path.join(playwrightDir, 'Temporaries') const globalSessionFile = path.join(playwrightDir, 'session.js') /** * See https://playwright.dev/docs/test-configuration. */ const config: PlaywrightTestConfig<{}, WorkerConfigOptions> = { testDir, outputDir, forbidOnly: !!process.env['CI'], retries: process.env['CI'] ? 2 : 0, workers: process.env['CI'] ? 1 : '100%', reporter: 'list', timeout: 60000, /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { baseURL: `${directus_config.PUBLIC_URL}:${directus_config.PORT}`, trace: 'on-first-retry', globalSessionFile }, projects: [ { name: 'setup', testMatch: /.*\.setup\.ts/ }, { name: 'chromium', use: { ...devices['Desktop Chrome'] }, dependencies: ['setup'] }, { name: 'firefox', use: { ...devices['Desktop Firefox'] }, dependencies: ['setup'] }, { name: 'webkit', use: { ...devices['Desktop Safari'] }, dependencies: ['setup'] }, /* Test against mobile viewports. */ { name: 'Mobile Chrome', use: { ...devices['Pixel 5'] }, dependencies: ['setup'] }, { name: 'Mobile Safari', use: { ...devices['iPhone 12'] }, dependencies: ['setup'] } ], /* Run your local dev server before starting the tests */ webServer: { command: './setup.sh start-fg', url: `${directus_config.PUBLIC_URL}:${directus_config.PORT}`, reuseExistingServer: !process.env['CI'], gracefulShutdown: { signal: 'SIGTERM', timeout: 2000 } } } export default defineConfig(config)