import type { PlaywrightTestConfig } from "@playwright/test"; import { devices } from "@playwright/test"; import path from "path"; // Resolve relative to this file so paths are correct regardless of cwd // (VS Code Playwright extension runs from the workspace root, not e2e-tests/). require("dotenv").config({ path: path.join(__dirname, ".env") }); const defaultBackendPort = process.env.E2E_BACKEND_PORT || "8070"; const defaultFrontendPort = process.env.E2E_FRONTEND_PORT || "3070"; export const baserowConfig = { PUBLIC_WEB_FRONTEND_URL: process.env.PUBLIC_WEB_FRONTEND_URL ? process.env.PUBLIC_WEB_FRONTEND_URL : `http://localhost:${defaultFrontendPort}`, PUBLIC_BACKEND_URL: process.env.PUBLIC_BACKEND_URL ? process.env.PUBLIC_BACKEND_URL : `http://localhost:${defaultBackendPort}`, BUILDER_PREVIEW_URL: process.env.BASEROW_BUILDER_PREVIEW_URL ?? process.env.PUBLIC_WEB_FRONTEND_URL ?? `http://localhost:${defaultFrontendPort}`, BASEROW_FRONTEND_COOKIE_PREFIX: process.env.BASEROW_FRONTEND_COOKIE_PREFIX ?? process.env.NUXT_PUBLIC_BASEROW_FRONTEND_COOKIE_PREFIX ?? process.env.E2E_FRONTEND_COOKIE_PREFIX ?? "baserow_e2e_", }; /** * Development config to be used when running locally * See https://playwright.dev/docs/test-configuration. */ const config: PlaywrightTestConfig = { testDir: path.join(__dirname, "tests"), /* Maximum time one test can run for. */ timeout: 30 * 1000, expect: { /** * Maximum time expect() should wait for the condition to be met. * For example in `await expect(locator).toHaveText();` */ timeout: 10000, }, fullyParallel: true, /* Fail the build on CI if you accidentally left test.only in the source code. */ forbidOnly: !!process.env.CI ? true : false, retries: !!process.env.CI ? 3 : 0, workers: !!process.env.CI ? 1 : 3, /* Reporter to use. See https://playwright.dev/docs/test-reporters */ reporter: !!process.env.CI ? [["blob"], ["html"]] : "list", /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ use: { /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: "on-first-retry", video: "on-first-retry", // Kuma's panel would otherwise open over the pages under test. storageState: { cookies: [], origins: [ { origin: baserowConfig.PUBLIC_WEB_FRONTEND_URL, localStorage: [{ name: "baserow.rightSidebarOpen", value: "false" }], }, ], }, nuxt: { host: baserowConfig.PUBLIC_WEB_FRONTEND_URL, // Disable fixture loading - test against running server, not local Nuxt app fixture: false, }, }, projects: [ { name: "chrome", use: { ...devices["Desktop Chrome"], ...(process.env.CI ? { channel: "chrome" } : {}), }, }, { name: "firefox", use: { ...devices["Desktop Firefox"], }, }, ], }; export default config;