-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplaywright.config.ts
More file actions
46 lines (43 loc) · 1.56 KB
/
Copy pathplaywright.config.ts
File metadata and controls
46 lines (43 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import { defineConfig, devices } from "@playwright/test";
/**
* Playwright E2E config (industry-standard Next.js pattern).
*
* - Uses port 3100 by default so a normal `next dev` on :3000 does not collide.
* - Local: starts `next dev -p <port>` (no prior build) unless a server is already on that port.
* - CI: assumes `npm run build` ran in the same job; starts `PORT=<port> npm run start`.
*
* Skip auto-start: `PLAYWRIGHT_SKIP_WEB_SERVER=1 npx playwright test` (point `PLAYWRIGHT_BASE_URL` at your preview).
*/
const e2ePort = process.env.PLAYWRIGHT_E2E_PORT ?? "3100";
const baseURL =
process.env.PLAYWRIGHT_BASE_URL ?? `http://127.0.0.1:${e2ePort}`;
const webServer = process.env.PLAYWRIGHT_SKIP_WEB_SERVER
? undefined
: {
// `output: "standalone"` — `next start` is not supported; use the standalone server entry.
command: process.env.CI
? `cross-env PORT=${e2ePort} HOSTNAME=127.0.0.1 node .next/standalone/server.js`
: `npx next dev -p ${e2ePort}`,
url: baseURL,
reuseExistingServer: !process.env.CI,
timeout: 120_000,
};
export default defineConfig({
testDir: "e2e",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: [
["list"],
["html", { open: "never", outputFolder: "playwright-report" }],
],
use: {
baseURL,
trace: "on-first-retry",
screenshot: "only-on-failure",
video: "retain-on-failure",
},
projects: [{ name: "chromium", use: { ...devices["Desktop Chrome"] } }],
webServer,
});