Path: blob/main/tests/integration/playwright/playwright.config.ts
12921 views
import { defineConfig, devices } from '@playwright/test';12/**3* Read environment variables from file.4* https://github.com/motdotla/dotenv5*/6// require('dotenv').config();78const isCI = !!process.env.CI;910/**11* See https://playwright.dev/docs/test-configuration.12*/13export default defineConfig({14/* Look for test files in the "tests" directory, relative to this configuration file. */15testDir: "./tests",16snapshotPathTemplate: "{testDir}/__screenshots__/{testFilePath}/{platform}/{arg}{ext}",17/* Maximum time one test can run for. */18timeout: 30 * 1000,19expect: {20/**21* Maximum time expect() should wait for the condition to be met.22* For example in `await expect(locator).toHaveText();`23*/24timeout: 5000,25},26/* Run tests in files in parallel */27fullyParallel: true,28/* Fail the build on CI if you accidentally left test.only in the source code. */29forbidOnly: isCI,30/* Retry on CI only */31retries: isCI ? 2 : 0,32/* Opt out of parallel tests on CI. */33workers: isCI ? 1 : undefined,34/* Reporter to use. See https://playwright.dev/docs/test-reporters */35reporter: [36["html", { open: "never" }],37isCI ? ['github'] : ['line'],38],39/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */40use: {41/* Base URL to use in actions like `await page.goto('/')`. */42baseURL: 'http://127.0.0.1:8080',4344/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */45trace: "on-first-retry",46},47/* Configure projects for major browsers */48projects: [49{50name: "chromium",51use: { ...devices['Desktop Chrome'] },52},5354{55name: "firefox",56use: {...devices["Desktop Firefox"] },57},5859{60name: "webkit",61use: { ...devices["Desktop Safari"] },62},63/* Test against mobile viewports. */64// {65// name: 'Mobile Chrome',66// use: {67// ...devices['Pixel 5'],68// },69// },70// {71// name: 'Mobile Safari',72// use: {73// ...devices['iPhone 12'],74// },75// },7677/* Test against branded browsers. */78// {79// name: 'Microsoft Edge',80// use: {81// channel: 'msedge',82// },83// },84// {85// name: 'Google Chrome',86// use: {87// channel: 'chrome',88// },89// },90],91/* Folder for test artifacts such as screenshots, videos, traces, etc. */92// outputDir: 'test-results/',9394/* Run your local dev server before starting the tests */95/* We use python for this but we could also try using another tool */96webServer: [97{98// HTTP server for rendered HTML files99command: 'uv run python -m http.server 8080',100url: 'http://127.0.0.1:8080',101reuseExistingServer: !isCI,102cwd: '../../docs/playwright',103stderr: 'ignore', // Suppress verbose HTTP request logs104},105{106// Socket.IO multiplex server for RevealJS107command: 'npm start',108url: 'http://127.0.0.1:1948',109reuseExistingServer: !isCI,110cwd: './multiplex-server',111timeout: 10000,112stderr: 'ignore', // Suppress verbose logs113}114],115});116117118