Skip to content

Commit 22ccbda

Browse files
committed
fix(test): allocates dynamic port for E2E to avoid collisions
1 parent 744cd81 commit 22ccbda

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
"test:watch": "vitest --config vitest.config.ts",
1313
"deploy": "wrangler deploy",
1414
"typecheck": "tsc --noEmit",
15-
"test:e2e": "playwright test"
15+
"test:e2e": "E2E_PORT=$(node -e \"const s=require('net').createServer();s.listen(0,()=>{console.log(s.address().port);s.close()})\") playwright test"
1616
},
1717
"dependencies": {
1818
"@octokit/core": "^7.0.6",

playwright.config.ts

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

3+
const port = Number(process.env.E2E_PORT) || 5173;
4+
35
export default defineConfig({
46
testDir: "./e2e",
57
reporter: [["html", { open: "never" }]],
68
use: {
7-
baseURL: "http://localhost:5173",
9+
baseURL: `http://localhost:${port}`,
810
trace: "on-first-retry",
911
},
1012
projects: [
@@ -14,8 +16,8 @@ export default defineConfig({
1416
},
1517
],
1618
webServer: {
17-
command: "pnpm dev",
18-
port: 5173,
19+
command: `pnpm exec vite dev --port ${port}`,
20+
url: `http://localhost:${port}`,
1921
timeout: 120_000,
2022
reuseExistingServer: !process.env.CI,
2123
},

0 commit comments

Comments
 (0)