From 8e0fc8f5afe7131a6f9e8405ed1fb283fe64a6b4 Mon Sep 17 00:00:00 2001 From: Raku Zeta Date: Thu, 4 Jul 2024 18:04:27 +0800 Subject: [PATCH 1/2] fix(playwright): use `npm run` to start the server on default port --- template/config/playwright/playwright.config.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/config/playwright/playwright.config.js b/template/config/playwright/playwright.config.js index 92075cc1..5ddfe3b5 100644 --- a/template/config/playwright/playwright.config.js +++ b/template/config/playwright/playwright.config.js @@ -103,8 +103,8 @@ export default defineConfig({ * Use the preview server on CI for more realistic testing. * Playwright will re-use the local server if there is already a dev-server running. */ - command: process.env.CI ? 'vite preview --port 5173' : 'vite dev', - port: 5173, + command: process.env.CI ? 'npm run preview' : 'npm run dev', + port: process.env.CI ? 4173 : 5173, reuseExistingServer: !process.env.CI } }) From 081ba3eb0a197e89dae9ad57d096a2d549d87495 Mon Sep 17 00:00:00 2001 From: Raku Zeta Date: Thu, 4 Jul 2024 19:44:02 +0800 Subject: [PATCH 2/2] fix: use conditional baseURL --- template/config/playwright/playwright.config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/template/config/playwright/playwright.config.js b/template/config/playwright/playwright.config.js index 5ddfe3b5..cbb25003 100644 --- a/template/config/playwright/playwright.config.js +++ b/template/config/playwright/playwright.config.js @@ -34,7 +34,7 @@ export default defineConfig({ /* Maximum time each action such as `click()` can take. Defaults to 0 (no limit). */ actionTimeout: 0, /* Base URL to use in actions like `await page.goto('/')`. */ - baseURL: 'http://localhost:5173', + baseURL: process.env.CI ? 'http://localhost:4173' : 'http://localhost:5173', /* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ trace: 'on-first-retry',