Skip to content

Commit b48f5ea

Browse files
committed
Configure Playwright with env vars.
1 parent 3c07ac2 commit b48f5ea

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

playwright.config.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
import { defineConfig, devices } from "@playwright/test"
22

3+
const JSON_REPORT = process.env.JSON_REPORT === "1"
4+
const DEV_SERVER_PORT = process.env.DEV_SERVER_PORT || 3000
5+
36
/**
47
* @see https://playwright.dev/docs/test-configuration
58
*/
@@ -10,9 +13,11 @@ export default defineConfig({
1013
forbidOnly: !!process.env.CI,
1114
retries: process.env.CI ? 2 : 0,
1215
workers: process.env.CI ? 1 : undefined,
13-
reporter: "html",
16+
reporter: JSON_REPORT
17+
? [["list"], ["json", { outputFile: "./test/test-results.json" }]]
18+
: [["html"]],
1419
use: {
15-
baseURL: "http://localhost:3000",
20+
baseURL: `http://localhost:${DEV_SERVER_PORT}`,
1621
trace: "on-first-retry",
1722
},
1823

@@ -25,7 +30,7 @@ export default defineConfig({
2530

2631
webServer: {
2732
command: "pnpm dev",
28-
url: "http://localhost:3000",
33+
url: `http://localhost:${DEV_SERVER_PORT}`,
2934
reuseExistingServer: !process.env.CI,
3035
},
3136
})

0 commit comments

Comments
 (0)