Files
novalon-manage-system/novalon-manage-web/playwright.config.ts
T
张翔 af44c23f21 refactor(security): 重构安全配置并优化测试环境
- 移除旧的测试套件和UAT测试文件
- 更新密码编码器配置使用BCrypt strength=12
- 添加用户角色关联表和相关服务
- 优化前端日期显示格式
- 清理无用资源和配置文件
- 增强测试数据管理和清理功能
2026-03-27 13:00:22 +08:00

111 lines
2.9 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
import path from 'path';
import { fileURLToPath } from 'url';
const __filename = fileURLToPath(import.meta.url);
const __dirname = path.dirname(__filename);
const isHeadless = process.env.PLAYWRIGHT_HEADLESS === 'true' || process.env.CI === 'true';
const baseURL = process.env.TEST_BASE_URL || process.env.VITE_BASE_URL || 'http://localhost:3001';
export default defineConfig({
testDir: './e2e',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: 3,
workers: process.env.CI ? 2 : 4,
reporter: [
['html', { outputFolder: 'playwright-report' }],
['json', { outputFile: 'test-results/results.json' }],
['junit', { outputFile: 'test-results/junit.xml' }],
['list'],
['./e2e/customReporter.ts']
],
timeout: 120000,
expect: {
timeout: 30000,
toHaveScreenshot: { threshold: 0.2 },
toMatchSnapshot: { threshold: 0.2 }
},
use: {
baseURL: baseURL,
trace: process.env.CI ? 'retain-on-failure' : 'on-first-retry',
screenshot: 'only-on-failure',
video: process.env.CI ? 'retain-on-failure' : 'on-first-retry',
actionTimeout: 30000,
navigationTimeout: 60000,
headless: isHeadless,
locale: 'zh-CN',
timezoneId: 'Asia/Shanghai',
ignoreHTTPSErrors: true,
bypassCSP: true,
viewport: { width: 1280, height: 720 },
launchOptions: {
slowMo: process.env.CI ? 0 : 100
},
contextOptions: {
permissions: ['geolocation'],
geolocation: { latitude: 35.6895, longitude: 139.6917 },
userAgent: 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36'
}
},
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
launchOptions: {
args: [
'--disable-blink-features=AutomationControlled',
'--disable-dev-shm-usage',
'--no-sandbox'
]
}
},
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
launchOptions: {
firefoxUserPrefs: {
'dom.webdriver.enabled': false,
'useAutomationExtension': false
}
}
},
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
{
name: 'Mobile Chrome',
use: {
...devices['Pixel 5'],
launchOptions: {
args: [
'--disable-blink-features=AutomationControlled',
'--disable-dev-shm-usage'
]
}
},
},
],
webServer: {
command: 'npm run dev',
url: 'http://localhost:3001',
reuseExistingServer: !process.env.CI,
timeout: 120000,
stdout: 'pipe',
stderr: 'pipe'
},
globalSetup: path.resolve(__dirname, './e2e/global-setup.ts'),
globalTeardown: path.resolve(__dirname, './e2e/global-teardown.ts'),
});