this repo has no description
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 91 lines 2.6 kB view raw
1import { defineConfig, devices } from "@playwright/test"; 2import { getAppPort, getInspectorPort, type AppName } from "./apps"; 3 4declare const process: typeof nodeProcess; 5 6export function configurePlaywright( 7 app: AppName, 8 { 9 // Do we run on CI? 10 isCI = Boolean(process.env.CI), 11 // Do we run on workers (`wrangler dev`) or on Node (`next dev`) 12 isWorker = true, 13 // Tests with multiple browsers 14 multipleBrowsers = false, 15 // Whether to run tests in single file in parallel 16 parallel = true, 17 // Use the turbopack runtime 18 useTurbopack = false, 19 } = {} 20) { 21 const port = getAppPort(app, { isWorker }); 22 const inspectorPort = getInspectorPort(app); 23 const baseURL = `http://localhost:${port}`; 24 let command: string; 25 let timeout: number; 26 if (isWorker) { 27 // Do not build on CI - there is a preceding build step 28 command = isCI ? "" : `pnpm ${useTurbopack ? "build:worker-turbopack" : "build:worker"} && `; 29 30 const env = app === "r2-incremental-cache" ? "--env e2e" : ""; 31 command += `pnpm preview:worker -- --port ${port} --inspector-port ${inspectorPort} ${env}`; 32 timeout = 800_000; 33 } else { 34 timeout = 100_000; 35 command = `pnpm dev --port ${port}`; 36 } 37 38 const projects = [ 39 { 40 name: "chromium", 41 use: { ...devices["Desktop Chrome"] }, 42 }, 43 { 44 name: "firefox", 45 use: { ...devices["Desktop Firefox"] }, 46 }, 47 { 48 name: "webkit", 49 use: { ...devices["Desktop Safari"] }, 50 }, 51 ]; 52 if (!multipleBrowsers) { 53 projects.length = 1; 54 } 55 56 /** 57 * See https://playwright.dev/docs/test-configuration. 58 */ 59 return defineConfig({ 60 testDir: "./", 61 /* ignore runtime specific tests */ 62 testIgnore: isWorker ? "*next.spec.ts" : "*cloudflare.spec.ts", 63 /* Run tests in files in parallel */ 64 fullyParallel: parallel, 65 /* Fail the build on CI if you accidentally left test.only in the source code. */ 66 forbidOnly: isCI, 67 /* Retry on CI only */ 68 retries: isCI ? 2 : 0, 69 /* Opt out of parallel tests on CI. */ 70 workers: isCI ? 1 : undefined, 71 /* Reporter to use. See https://playwright.dev/docs/test-reporters */ 72 reporter: "html", 73 /* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */ 74 use: { 75 /* Base URL to use in actions like `await page.goto('/')`. */ 76 baseURL, 77 /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ 78 trace: "on-first-retry", 79 }, 80 81 projects, 82 83 /* Run your local dev server before starting the tests */ 84 webServer: { 85 command, 86 url: baseURL, 87 reuseExistingServer: !isCI, 88 timeout, 89 }, 90 }); 91}