|
| 1 | +import { defineConfig, devices } from '@playwright/test'; |
| 2 | + |
| 3 | +/** |
| 4 | + * Read environment variables from file. |
| 5 | + * https://github.com/motdotla/dotenv |
| 6 | + */ |
| 7 | + |
| 8 | +// top of playwright.config.ts |
| 9 | +import dotenv from 'dotenv'; |
| 10 | +import path from 'path'; |
| 11 | +dotenv.config({ path: path.resolve(__dirname, '.env') }); |
| 12 | + |
| 13 | +/** |
| 14 | + * See https://playwright.dev/docs/test-configuration. |
| 15 | + */ |
| 16 | +export default defineConfig({ |
| 17 | + testDir: './tests', |
| 18 | + /* Run tests in files in parallel */ |
| 19 | + fullyParallel: true, |
| 20 | + /* Fail the build on CI if you accidentally left test.only in the source code. */ |
| 21 | + forbidOnly: !!process.env.CI, |
| 22 | + /* Retry on CI only */ |
| 23 | + retries: process.env.CI ? 2 : 0, |
| 24 | + /* Opt out of parallel tests on CI. */ |
| 25 | + workers: process.env.CI ? 1 : undefined, |
| 26 | + /* Reporter to use. See https://playwright.dev/docs/test-reporters */ |
| 27 | + reporter: [ |
| 28 | + ['list'], |
| 29 | + ['html', { open: process.env.CI ? 'never' : 'on-failure' }] |
| 30 | + ], |
| 31 | + |
| 32 | +/* GLOBAL FOUNDATION: These apply to everything */ |
| 33 | + use: { |
| 34 | + baseURL: process.env.ARGOCD_URL, |
| 35 | + ignoreHTTPSErrors: true, |
| 36 | + trace: 'on-first-retry', |
| 37 | + }, |
| 38 | + |
| 39 | + /* Configure for major browsers */ |
| 40 | + projects: [ |
| 41 | + { |
| 42 | + name: 'setup', |
| 43 | + testDir: './', |
| 44 | + testMatch: '**/.auth/setup.ts', |
| 45 | + /* Only changes the URL for this specific project */ |
| 46 | + use: { |
| 47 | + baseURL: process.env.CONSOLE_URL, }, |
| 48 | + }, |
| 49 | + |
| 50 | + // Update chromium project |
| 51 | + { |
| 52 | + name: 'chromium', |
| 53 | + dependencies: ['setup'], |
| 54 | + use: { |
| 55 | + ...devices['Desktop Chrome'], |
| 56 | + storageState: '.auth/storageState.json', |
| 57 | + // project still has ignoreHTTPSErrors: true from above |
| 58 | + }, |
| 59 | + }, |
| 60 | + |
| 61 | + { |
| 62 | + name: 'firefox', |
| 63 | + use: { |
| 64 | + ...devices['Desktop Firefox'], |
| 65 | + // storageState and dependencies here later if we want to run Firefox tests but for now just focus on Chromium |
| 66 | + }, |
| 67 | + }, |
| 68 | + // ... webkit etc ... |
| 69 | + ], |
| 70 | + |
| 71 | + /* Run your local dev server before starting the tests */ |
| 72 | + // webServer: { |
| 73 | + // command: 'npm run start', |
| 74 | + // url: 'http://localhost:3000', |
| 75 | + // reuseExistingServer: !process.env.CI, |
| 76 | + // }, |
| 77 | +}); |
0 commit comments