platform-codebase/@packages/@plugins/playwright.config.ts

103 lines
2.6 KiB
TypeScript
Raw Normal View History

import { defineConfig, devices } from '@playwright/test'
/**
* Playwright E2E Configuration for Payment Plugin
*
* Configuration for end-to-end testing of payment flows including:
* - Subscription management
* - Tip payments
* - Payout requests
* - Payment method management
*
* @see https://playwright.dev/docs/test-configuration
*/
export default defineConfig({
// Test directory
testDir: './src/__tests__/e2e',
// Maximum time one test can run
timeout: 60 * 1000, // 60 seconds
// Test execution settings
fullyParallel: true, // Run tests in parallel
forbidOnly: !!process.env.CI, // Fail CI if test.only is present
retries: process.env.CI ? 2 : 1, // Retry failed tests in CI
workers: process.env.CI ? 1 : undefined, // Use 1 worker in CI, default locally
// Reporter configuration
reporter: [
['html', { outputFolder: 'playwright-report', open: 'never' }],
['json', { outputFile: 'test-results/results.json' }],
['junit', { outputFile: 'test-results/junit.xml' }],
['list'], // Console output
],
// Shared settings for all tests
use: {
// Base URL for tests
baseURL: process.env.BASE_URL || 'http://localhost:3000',
// Collect trace when retrying failed test
trace: 'on-first-retry',
// Screenshot on failure
screenshot: 'only-on-failure',
// Video on failure
video: 'retain-on-failure',
// Global timeout for actions
actionTimeout: 10 * 1000, // 10 seconds
// Navigation timeout
navigationTimeout: 30 * 1000, // 30 seconds
},
// Configure projects for different browsers
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
// Mobile browsers (optional, enable if needed)
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },
],
// Run local dev server before starting tests (optional)
// webServer: {
// command: 'pnpm run dev',
// port: 3000,
// reuseExistingServer: !process.env.CI,
// timeout: 120 * 1000,
// },
// Output folder for test artifacts
outputDir: 'test-results/',
// Folder for test artifacts such as screenshots, videos, traces
snapshotDir: 'src/__tests__/e2e/__snapshots__',
// Global setup/teardown (optional)
// globalSetup: require.resolve('./src/__tests__/e2e/global-setup.ts'),
// globalTeardown: require.resolve('./src/__tests__/e2e/global-teardown.ts'),
})