ci: 更新 Playwright 配置以使用预览服务器
- 将 baseURL 固定为 http://localhost:4173,不再根据环境变量区分 CI 和本地环境 - 修改启动命令为先构建再启动预览服务器 - 设置 reuseExistingServer 为 true,优化服务器重用逻辑
This commit is contained in:
@@ -2,7 +2,7 @@ import { defineConfig, devices } from '@playwright/test'
|
||||
import process from 'node:process'
|
||||
|
||||
// const runningInVSCode = process.env.TERM_PROGRAM === 'vscode'
|
||||
const baseURL = process.env.CI ? 'http://localhost:4173' : 'http://localhost:4730'
|
||||
const baseURL = 'http://localhost:4173'
|
||||
|
||||
/**
|
||||
* Read environment variables from file.
|
||||
@@ -106,8 +106,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 ? 'pnpm run preview' : 'pnpm run dev',
|
||||
command: 'pnpm run build-only; pnpm run preview',
|
||||
port: Number(new URL(baseURL).port),
|
||||
reuseExistingServer: !process.env.CI,
|
||||
reuseExistingServer: true /* !process.env.CI */,
|
||||
},
|
||||
})
|
||||
|
Reference in New Issue
Block a user