Files
CRM_Montzar/playwright.config.ts
T

51 lines
1.4 KiB
TypeScript

import { defineConfig } from '@playwright/test';
import { existsSync, readFileSync } from 'node:fs';
/** e2e/.env (gitignored): E2E_USER, E2E_PASSWORD, ... */
const envFile = 'e2e/.env';
if (existsSync(envFile)) {
for (const line of readFileSync(envFile, 'utf8').split(/\r?\n/)) {
const m = line.match(/^\s*([A-Z0-9_]+)\s*=\s*(.*?)\s*$/);
if (m && process.env[m[1]!] === undefined) process.env[m[1]!] = m[2]!.replace(/^["']|["']$/g, '');
}
}
const baseURL = process.env.E2E_BASE_URL || 'http://127.0.0.1:5173';
const isLocal = /^https?:\/\/(127\.0\.0\.1|localhost)/.test(baseURL);
export default defineConfig({
testDir: 'e2e',
timeout: 60_000,
expect: { timeout: 15_000 },
fullyParallel: false,
workers: 1,
retries: 0,
reporter: [['list'], ['html', { open: 'never' }]],
use: {
baseURL,
channel: process.env.E2E_CHANNEL || (process.platform === 'win32' ? 'msedge' : undefined),
locale: 'fa-IR',
timezoneId: 'Asia/Tehran',
viewport: { width: 1366, height: 860 },
screenshot: 'only-on-failure',
trace: 'retain-on-failure',
},
projects: [
{ name: 'setup', testMatch: /auth\.setup\.ts/ },
{
name: 'smoke',
testMatch: /.*\.spec\.ts/,
dependencies: ['setup'],
use: { storageState: 'e2e/.auth/user.json' },
},
],
webServer: isLocal
? {
command: 'npm run dev:web',
url: baseURL,
reuseExistingServer: true,
timeout: 120_000,
}
: undefined,
});