Some checks failed
DevStar Studio Auto Test Pipeline / unit-frontend-test (push) Has been cancelled
DevStar Studio Auto Test Pipeline / unit-backend-test (push) Has been cancelled
DevStar Studio CI/CD Pipeline / build-and-push-x86-64-docker-image (push) Has been cancelled
DevStar E2E Test / e2e-test (push) Has been cancelled
Reviewed-on: #1 Co-authored-by: jiaojm <13763605353@163.com> Co-committed-by: jiaojm <13763605353@163.com>
64 lines
1.6 KiB
TypeScript
64 lines
1.6 KiB
TypeScript
import { devices } from '@playwright/test';
|
|
import { env } from 'node:process';
|
|
import type { PlaywrightTestConfig } from '@playwright/test';
|
|
|
|
const BASE_URL = env.DEVSTAR_URL?.replace?.(/\/$/g, '') || 'http://localhost:3000';
|
|
|
|
const config: PlaywrightTestConfig = {
|
|
testDir: './specs',
|
|
|
|
timeout: 500000,
|
|
expect: {
|
|
timeout: 15000,
|
|
},
|
|
forbidOnly: Boolean(env.CI),
|
|
retries: 0,
|
|
reporter: [['html', {
|
|
outputFolder: 'playwright-report/html',
|
|
open: 'never'
|
|
}]],
|
|
|
|
use: {
|
|
headless: true,
|
|
locale: 'zh-CN',
|
|
timezoneId: 'Asia/Shanghai',
|
|
actionTimeout: 15000,
|
|
navigationTimeout: 15000,
|
|
baseURL: BASE_URL,
|
|
trace: 'on-first-retry',
|
|
screenshot: 'only-on-failure',
|
|
},
|
|
projects: [
|
|
// 1. 冒烟门禁项目 (对应 make smoke-test)
|
|
{
|
|
name: 'smoke-gate',
|
|
testMatch: /.*smoke\.test\.ts/,
|
|
use: {
|
|
...devices['Desktop Chrome'],
|
|
},
|
|
},
|
|
|
|
// 2. 全量回归项目 (对应 make e2e-test)
|
|
{
|
|
name: 'full-regression',
|
|
testMatch: /specs\/.*\.test\.ts/,
|
|
testIgnore: /.*smoke\.test\.ts/,
|
|
use: {
|
|
...devices['Desktop Chrome'],
|
|
},
|
|
},
|
|
],
|
|
outputDir: 'playwright-report/test-artifacts/',
|
|
snapshotDir: 'playwright-report/test-snapshots/',
|
|
};
|
|
|
|
const skipInstall = env.E2E_SKIP_INSTALL === 'true';
|
|
|
|
if (skipInstall) {
|
|
console.log(`已跳过 global-setup.`);
|
|
} else {
|
|
console.log(`[Playwright Config] 探测结果: E2E_SKIP_INSTALL is not 'true'. 已启用 global-setup.`);
|
|
config.globalSetup = require.resolve('./global-setup.ts');
|
|
}
|
|
export default config satisfies PlaywrightTestConfig;
|