playwright/playwright.config.js
2025-03-04 17:13:49 +08:00

71 lines
1.6 KiB
JavaScript

// @ts-check
const {defineConfig, devices} = require('@playwright/test');
/**
* @see https://playwright.dev/docs/test-configuration
*/
module.exports = defineConfig({
testDir: './tests',
/* 测试超时时间 */
timeout: 120 * 1000,
/* 每个测试的预期状态 */
expect: {
/**
* 断言超时时间
*/
timeout: 15000
},
/* 测试运行并发数 */
fullyParallel: false,
/* 失败重试次数 */
retries: 0,
/* 测试报告相关 */
reporter: [
['html', {open: 'never'}],
['list']
],
/* 共享设置 */
use: {
/* 基础URL */
// baseURL: 'http://localhost:3000',
/* 收集测试追踪信息 */
trace: 'on-first-retry',
/* 自动截图 */
screenshot: 'only-on-failure',
/* 录制视频 */
video: 'on-first-retry',
},
/* 配置不同的浏览器项目 */
projects: [
{
name: 'chromium',
use: {...devices['Desktop Chrome']},
},
{
name: 'firefox',
use: {...devices['Desktop Firefox']},
},
{
name: 'webkit',
use: {...devices['Desktop Safari']},
},
/* 移动设备测试 */
{
name: 'Mobile Chrome',
use: {...devices['Pixel 5']},
},
{
name: 'Mobile Safari',
use: {...devices['iPhone 12']},
},
],
/* 本地开发服务器配置 */
// webServer: {
// command: 'npm run start',
// port: 3000,
// reuseExistingServer: !process.env.CI,
// },
});