101 lines
2.4 KiB
TypeScript
101 lines
2.4 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import path from 'path';
|
|
|
|
const authFile = path.join(__dirname, 'playwright/.auth/user.json');
|
|
|
|
/**
|
|
* Playwright configuration for admin-dashboard e2e tests
|
|
* @see https://playwright.dev/docs/test-configuration
|
|
*/
|
|
export default defineConfig({
|
|
// Directory containing test files
|
|
testDir: './e2e',
|
|
|
|
// Run tests in parallel
|
|
fullyParallel: true,
|
|
|
|
// Fail the build on CI if you accidentally left test.only in the source code
|
|
forbidOnly: !!process.env.CI,
|
|
|
|
// Retry failed tests (2 retries on CI, 0 locally)
|
|
retries: process.env.CI ? 2 : 0,
|
|
|
|
// Limit parallel workers on CI
|
|
workers: process.env.CI ? 1 : undefined,
|
|
|
|
// Reporter configuration
|
|
reporter: [
|
|
['html', { open: 'never' }],
|
|
['list'],
|
|
],
|
|
|
|
// Shared settings for all projects
|
|
use: {
|
|
// Base URL for navigation (parameterized via ADMIN_DASHBOARD_PORT)
|
|
baseURL: `http://localhost:${process.env.ADMIN_DASHBOARD_PORT}`,
|
|
|
|
// Capture screenshot on failure
|
|
screenshot: 'only-on-failure',
|
|
|
|
// Capture trace on failure (for debugging)
|
|
trace: 'on-first-retry',
|
|
|
|
// Default timeout for actions
|
|
actionTimeout: 10000,
|
|
},
|
|
|
|
// Test timeout
|
|
timeout: 30000,
|
|
|
|
// Configure projects for different browsers
|
|
projects: [
|
|
// Setup project - runs authentication once
|
|
{
|
|
name: 'setup',
|
|
testMatch: /.*\.setup\.ts/,
|
|
},
|
|
// Main test projects - depend on setup for authentication
|
|
{
|
|
name: 'chromium',
|
|
use: {
|
|
...devices['Desktop Chrome'],
|
|
storageState: authFile,
|
|
},
|
|
dependencies: ['setup'],
|
|
},
|
|
{
|
|
name: 'firefox',
|
|
use: {
|
|
...devices['Desktop Firefox'],
|
|
storageState: authFile,
|
|
},
|
|
dependencies: ['setup'],
|
|
},
|
|
{
|
|
name: 'webkit',
|
|
use: {
|
|
...devices['Desktop Safari'],
|
|
storageState: authFile,
|
|
},
|
|
dependencies: ['setup'],
|
|
},
|
|
// Mobile viewports
|
|
{
|
|
name: 'mobile-chrome',
|
|
use: {
|
|
...devices['Pixel 5'],
|
|
storageState: authFile,
|
|
},
|
|
dependencies: ['setup'],
|
|
},
|
|
],
|
|
|
|
// Run local dev server before starting tests (optional)
|
|
// Uncomment if you want Playwright to start the server automatically
|
|
// webServer: {
|
|
// command: 'npm start',
|
|
// url: `http://localhost:${process.env.ADMIN_DASHBOARD_PORT}`,
|
|
// reuseExistingServer: !process.env.CI,
|
|
// timeout: 120000,
|
|
// },
|
|
});
|