61 lines
1.7 KiB
JavaScript
61 lines
1.7 KiB
JavaScript
// @ts-check
|
|
const {defineConfig, devices} = require('@playwright/test');
|
|
|
|
/**
|
|
* @see https://playwright.dev/docs/test-configuration
|
|
*/
|
|
module.exports = defineConfig({
|
|
testDir: './tests/e2e',
|
|
/* 测试超时时间 */
|
|
timeout: 60 * 60 * 1000, // 1小时
|
|
/* 每个测试的预期状态 */
|
|
expect: {
|
|
timeout: parseInt(process.env.EXPECT_TIMEOUT || '30000', 10)
|
|
},
|
|
/* 测试运行并发数 */
|
|
fullyParallel: false,
|
|
forbidOnly: !!process.env.CI,
|
|
/* 失败重试次数 */
|
|
retries: process.env.CI ? 2 : 0,
|
|
workers: 1,
|
|
/* 测试报告相关 */
|
|
reporter: 'html',
|
|
/* 共享设置 */
|
|
use: {
|
|
/* 基础URL */
|
|
baseURL: process.env.BASE_URL,
|
|
|
|
/* 收集测试追踪信息 */
|
|
trace: 'on-first-retry',
|
|
/* 自动截图 */
|
|
screenshot: 'only-on-failure',
|
|
/* 录制视频 */
|
|
video: 'retain-on-failure',
|
|
/* 浏览器配置 */
|
|
headless: process.env.BROWSER_HEADLESS === 'true',
|
|
viewport: {
|
|
width: parseInt(process.env.VIEWPORT_WIDTH || '1920', 10),
|
|
height: parseInt(process.env.VIEWPORT_HEIGHT || '1080', 10)
|
|
},
|
|
/* 浏览器启动选项 */
|
|
launchOptions: {
|
|
slowMo: parseInt(process.env.BROWSER_SLOW_MO || '50', 10),
|
|
timeout: parseInt(process.env.BROWSER_TIMEOUT || '30000', 10)
|
|
}
|
|
},
|
|
|
|
/* 配置不同的浏览器项目 */
|
|
projects: [
|
|
{
|
|
name: 'chromium',
|
|
use: {...devices['Desktop Chrome']},
|
|
},
|
|
],
|
|
|
|
/* 本地开发服务器配置 */
|
|
// webServer: {
|
|
// command: 'npm run start',
|
|
// port: 3000,
|
|
// reuseExistingServer: !process.env.CI,
|
|
// },
|
|
});
|