feat: 配置多环境支持
- 创建环境配置文件environments.ts - 支持development/staging/production三个环境 - 更新playwright.config.ts使用环境配置 - 创建.env.example环境变量示例 - 创建ENVIRONMENT.md环境配置指南 - 支持CI/CD集成配置
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import { defineConfig, devices } from '@playwright/test';
|
||||
import { getEnvironment } from './src/config/environments';
|
||||
|
||||
const env = getEnvironment();
|
||||
|
||||
export default defineConfig({
|
||||
testDir: './src/tests',
|
||||
fullyParallel: true,
|
||||
forbidOnly: !!process.env.CI,
|
||||
retries: process.env.CI ? 2 : 0,
|
||||
retries: env.retries,
|
||||
workers: process.env.CI ? 1 : undefined,
|
||||
reporter: [
|
||||
['html', { open: 'never' }],
|
||||
@@ -13,19 +16,22 @@ export default defineConfig({
|
||||
['line'],
|
||||
['list']
|
||||
],
|
||||
timeout: 120000,
|
||||
timeout: env.timeout,
|
||||
expect: {
|
||||
timeout: 30000
|
||||
},
|
||||
use: {
|
||||
baseURL: 'http://localhost:3001',
|
||||
trace: 'retain-on-failure',
|
||||
screenshot: 'only-on-failure',
|
||||
video: 'retain-on-failure',
|
||||
headless: true,
|
||||
baseURL: env.baseURL,
|
||||
trace: env.trace,
|
||||
screenshot: env.screenshot,
|
||||
video: env.video,
|
||||
headless: env.headless,
|
||||
viewport: { width: 1280, height: 720 },
|
||||
actionTimeout: 30000,
|
||||
navigationTimeout: 60000
|
||||
navigationTimeout: 60000,
|
||||
launchOptions: {
|
||||
slowMo: env.slowMo,
|
||||
},
|
||||
},
|
||||
projects: [
|
||||
{
|
||||
@@ -49,5 +55,10 @@ export default defineConfig({
|
||||
use: { ...devices['iPhone 12'] },
|
||||
},
|
||||
],
|
||||
webServer: undefined,
|
||||
webServer: env.name === 'development' ? {
|
||||
command: 'npm run dev',
|
||||
url: 'http://localhost:3001',
|
||||
timeout: 120000,
|
||||
reuseExistingServer: !process.env.CI,
|
||||
} : undefined,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user