|
| 1 | +import { defineConfig, devices } from "@playwright/test"; |
| 2 | +import path from "path"; |
| 3 | + |
| 4 | +const isCI = !!process.env.CI; |
| 5 | +const template: "vite" | "starter" = process.env.TEMPLATE; // Set to 'vite' or 'starter' to run only one |
| 6 | + |
| 7 | +const webServers = { |
| 8 | + vite: { |
| 9 | + name: "vite-template", |
| 10 | + command: "npm run build && npm run preview -- --port 4173", |
| 11 | + cwd: path.resolve(__dirname, "../templates/vite"), |
| 12 | + url: "http://localhost:4173", |
| 13 | + reuseExistingServer: !isCI, |
| 14 | + }, |
| 15 | + starter: { |
| 16 | + name: "starter-template", |
| 17 | + command: "npm run build && npm run preview -- --port 4174", |
| 18 | + cwd: path.resolve(__dirname, "../templates/starter"), |
| 19 | + url: "http://localhost:4174", |
| 20 | + reuseExistingServer: !isCI, |
| 21 | + }, |
| 22 | +}; |
| 23 | + |
| 24 | +const projects = { |
| 25 | + vite: { |
| 26 | + name: "vite", |
| 27 | + testMatch: "vite.spec.ts", |
| 28 | + use: { |
| 29 | + ...devices["Desktop Chrome"], |
| 30 | + baseURL: "http://localhost:4173", |
| 31 | + }, |
| 32 | + }, |
| 33 | + starter: { |
| 34 | + name: "starter", |
| 35 | + testMatch: "starter.spec.ts", |
| 36 | + use: { |
| 37 | + ...devices["Desktop Chrome"], |
| 38 | + baseURL: "http://localhost:4174", |
| 39 | + }, |
| 40 | + }, |
| 41 | +}; |
| 42 | + |
| 43 | +export default defineConfig({ |
| 44 | + testDir: "./e2e", |
| 45 | + fullyParallel: true, |
| 46 | + forbidOnly: isCI, |
| 47 | + retries: isCI ? 2 : 0, |
| 48 | + workers: isCI ? 1 : undefined, |
| 49 | + reporter: isCI ? [["github"], ["html", { open: "never" }]] : "html", |
| 50 | + use: { |
| 51 | + trace: "on-first-retry", |
| 52 | + }, |
| 53 | + projects: projects[template] ? [projects[template]] : Object.values(projects), |
| 54 | + webServer: webServers[template] ?? Object.values(webServers), |
| 55 | +}); |
0 commit comments