mascarpone/e2e/playwright.config.ts

72 lines
1.6 KiB
TypeScript
Raw Permalink Normal View History

2025-11-27 13:45:21 -06:00
import { defineConfig, devices } from '@playwright/test';
// purposefully not using ??: we want to replace empty empty string with default
const BASE_URL = process.env.BASE_URL || 'http://localhost:3000';
let addlConfig = {
retries: process.env.CI ? 2 : 0,
};
let projects = [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},
{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},
{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},
/* Test against mobile viewports. */
{
name: 'Mobile Chrome',
use: { ...devices['Pixel 5'] },
},
{
name: 'Mobile Safari',
use: { ...devices['iPhone 12'] },
},
];
const pfil = process.env.PROJECT_FILTER;
if (pfil) {
if (pfil.startsWith('!')) {
projects = projects.filter(p => p.name !== pfil.slice(1));
} else {
projects = projects.filter(p => p.name === pfil);
}
}
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './pages',
fullyParallel: true,
workers: 1,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: Boolean(process.env.CI),
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: BASE_URL,
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
},
/* Configure projects for major browsers */
projects,
...addlConfig,
});