playwright.config.ts•1.63 kB
import { defineConfig, devices } from '@playwright/test';
import path from 'path';
// import dotenv from 'dotenv';
// dotenv.config({ path: path.resolve(__dirname, '.env') });
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail build if test.only is accidentally left */
forbidOnly: !!process.env.CI,
/* Retry failed tests (2x on CI, none locally) */
retries: process.env.CI ? 2 : 0,
/* Use fewer workers on CI */
workers: process.env.CI ? 1 : undefined,
/* Reporters for better output visibility */
reporter: [
['list'],
['html', { open: 'never', outputFolder: 'test-report' }]
],
/* Common use options for all projects */
use: {
// ✅ Define your app’s base URL here (important for MCP context)
baseURL: process.env.BASE_URL || 'https://playwright.dev',
/* Enable screenshots, traces, and videos for MCP debugging */
screenshot: 'only-on-failure',
video: 'retain-on-failure',
trace: 'on-first-retry',
/* Headless mode by default */
headless: true,
},
/* Browser-specific configurations */
projects: [
{
name: 'Chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'Firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'WebKit',
use: { ...devices['Desktop Safari'] },
},
],
/* Optional: Run your app locally before tests */
// webServer: {
// command: 'npm run start',
// url: process.env.BASE_URL || 'http://localhost:3000',
// reuseExistingServer: !process.env.CI,
// },
});