Files
devstar/playwright.config.ts

54 lines
1.3 KiB
TypeScript
Raw Permalink Normal View History

2025-11-12 18:18:45 +08:00
import { devices } from '@playwright/test';
import { env } from 'node:process';
import type { PlaywrightTestConfig } from '@playwright/test';
2025-11-12 18:18:45 +08:00
const BASE_URL = env.DEVSTAR_URL?.replace?.(/\/$/g, '') || 'http://localhost:3000';
2025-11-12 19:52:09 +08:00
const config: PlaywrightTestConfig = {
2025-11-12 18:18:45 +08:00
testDir: './specs',
2025-11-14 09:25:43 +08:00
testMatch: /specs\/.*\.test\.ts/,
2025-11-12 19:52:09 +08:00
2025-11-12 18:18:45 +08:00
timeout: 500000,
expect: {
2025-11-12 18:18:45 +08:00
timeout: 15000,
},
forbidOnly: Boolean(env.CI),
retries: env.CI ? 2 : 0,
2025-11-12 19:52:09 +08:00
reporter: [['html', {
2025-11-12 18:18:45 +08:00
outputFolder: 'playwright-report/html',
open: 'never'
}]],
use: {
2025-11-12 18:18:45 +08:00
headless: true,
locale: 'zh-CN',
timezoneId: 'Asia/Shanghai',
2025-11-12 18:18:45 +08:00
actionTimeout: 15000,
navigationTimeout: 15000,
baseURL: BASE_URL,
trace: 'on-first-retry',
screenshot: 'only-on-failure',
},
projects: [
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
},
},
],
2025-11-12 18:18:45 +08:00
outputDir: 'playwright-report/test-artifacts/',
snapshotDir: 'playwright-report/test-snapshots/',
2025-11-12 19:52:09 +08:00
};
2025-11-13 21:13:14 +08:00
const skipInstall = env.E2E_SKIP_INSTALL === 'true';
if (skipInstall) {
console.log(`已跳过 global-setup.`);
2025-11-12 19:52:09 +08:00
} else {
2025-11-13 21:13:14 +08:00
console.log(`[Playwright Config] 探测结果: E2E_SKIP_INSTALL is not 'true'. 已启用 global-setup.`);
config.globalSetup = require.resolve('./global-setup.ts');
2025-11-12 19:52:09 +08:00
}
export default config satisfies PlaywrightTestConfig;