AFFiNE/playwright.config.ts

60 lines
1.7 KiB
TypeScript
Raw Normal View History

import type {
PlaywrightTestConfig,
PlaywrightWorkerOptions,
} from '@playwright/test';
// import { devices } from '@playwright/test';
2022-11-10 15:51:06 +03:00
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
// require('dotenv').config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
const config: PlaywrightTestConfig = {
testDir: './tests',
fullyParallel: true,
timeout: process.env.CI ? 50_000 : 30_000,
2022-11-10 15:51:06 +03:00
use: {
browserName:
(process.env.BROWSER as PlaywrightWorkerOptions['browserName']) ??
'chromium',
viewport: { width: 1440, height: 800 },
actionTimeout: 5 * 1000,
locale: 'en-US',
// Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer
// You can open traces locally(`npx playwright show-trace trace.zip`)
// or in your browser on [Playwright Trace Viewer](https://trace.playwright.dev/).
2022-11-10 15:51:06 +03:00
trace: 'on-first-retry',
// Record video only when retrying a test for the first time.
video: 'on-first-retry',
2022-11-10 15:51:06 +03:00
},
forbidOnly: !!process.env.CI,
workers: 4,
retries: 1,
// 'github' for GitHub Actions CI to generate annotations, plus a concise 'dot'
// default 'list' when running locally
// See https://playwright.dev/docs/test-reporters#github-actions-annotations
reporter: process.env.CI ? 'github' : 'list',
2022-11-10 15:51:06 +03:00
webServer: {
command: 'pnpm build && pnpm start -p 8080',
port: 8080,
timeout: 120 * 1000,
reuseExistingServer: !process.env.CI,
2023-02-05 13:41:18 +03:00
env: {
COVERAGE: process.env.COVERAGE || 'false',
2023-03-03 05:00:56 +03:00
ENABLE_DEBUG_PAGE: '1',
2023-02-05 13:41:18 +03:00
},
2022-11-10 15:51:06 +03:00
},
};
if (process.env.CI) {
config.retries = 3;
config.workers = '50%';
}
2022-11-10 15:51:06 +03:00
export default config;