|
| 1 | +import { resolve } from "node:path"; |
| 2 | +import { defineConfig, devices } from "@playwright/test"; |
| 3 | + |
| 4 | +function playwrightDir(partialPath: string) { |
| 5 | + return resolve("./tests/e2e", partialPath); |
| 6 | +} |
| 7 | + |
| 8 | +const CI = !!process.env.CI; |
| 9 | + |
| 10 | +export default defineConfig({ |
| 11 | + testDir: playwrightDir("specs"), |
| 12 | + outputDir: playwrightDir("results"), |
| 13 | + webServer: { |
| 14 | + command: "bun vite build && bun vite preview", |
| 15 | + port: 4173, |
| 16 | + }, |
| 17 | + use: { |
| 18 | + screenshot: "only-on-failure", |
| 19 | + trace: "retain-on-failure", |
| 20 | + }, |
| 21 | + testMatch: /(.+\.)?(test|spec)\.[jt]s/, |
| 22 | + reporter: CI |
| 23 | + ? [["github"]] |
| 24 | + : [ |
| 25 | + [ |
| 26 | + "html", |
| 27 | + { outputFolder: playwrightDir("./report"), open: "on-failure" }, |
| 28 | + ], |
| 29 | + ], |
| 30 | + projects: [ |
| 31 | + { |
| 32 | + name: "chromium", |
| 33 | + use: { |
| 34 | + ...devices["Desktop Chrome"], |
| 35 | + }, |
| 36 | + }, |
| 37 | + { |
| 38 | + name: "firefox", |
| 39 | + use: { |
| 40 | + ...devices["Desktop Firefox"], |
| 41 | + }, |
| 42 | + }, |
| 43 | + { |
| 44 | + name: "webkit", |
| 45 | + use: { |
| 46 | + ...devices["Desktop Safari"], |
| 47 | + }, |
| 48 | + }, |
| 49 | + { |
| 50 | + name: "Mobile Chrome", |
| 51 | + use: { ...devices["Pixel 5"] }, |
| 52 | + }, |
| 53 | + { |
| 54 | + name: "Mobile Safari", |
| 55 | + use: { ...devices["iPhone 14"] }, |
| 56 | + }, |
| 57 | + /** Test branded browsers */ |
| 58 | + { |
| 59 | + name: "google", |
| 60 | + use: { |
| 61 | + ...devices["Desktop Google Chrome"], |
| 62 | + }, |
| 63 | + }, |
| 64 | + { |
| 65 | + name: "msedge", |
| 66 | + use: { |
| 67 | + ...devices["Desktop Edge"], |
| 68 | + }, |
| 69 | + }, |
| 70 | + ], |
| 71 | +}); |
0 commit comments