playwright.config.ts Templateimport { defineConfig, devices } from "@playwright/test";
import dotenv from "dotenv";dotenv.config();
export default defineConfig({
testDir: "./tests",
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 2 : 0,
workers: process.env.CI ? 2 : undefined,
timeout: 30_000, // 30s per test
expect: {
timeout: 5_000, // 5s for retrying assertions
},
reporter: [
["html", { open: "never" }],
["list"],
],
use: {
baseURL: process.env.BASE_URL || "https://staging.targetqa.com",
trace: "retain-on-failure",
screenshot: "only-on-failure",
video: "retain-on-failure",
actionTimeout: 10_000,
navigationTimeout: 15_000,
},
projects: [
{
name: "chromium",
use: { ...devices["Desktop Chrome"] },
},
{
name: "firefox",
use: { ...devices["Desktop Firefox"] },
},
{
name: "webkit",
use: { ...devices["Desktop Safari"] },
},
],
});
---
BASE_URL=https://prod.targetqa.com npx playwright testInside tests, navigate with relative paths:
await page.goto("/dashboard"); // Automatically prepends baseURL!