- DB erp_test isolée (ports 3002/5174, erp_local intouché) - seed-test.ts déterministe: 3 users, 2 clients, 2 suppliers, 2 orders, 59 help articles - globalSetup truncate+reseed, webServer dual backend+frontend - 10 smoke tests: login, RBAC, orders, documents, help drawer, Ctrl+/ - Réorganisation tests/: e2e/ (Playwright) vs backend/ (vitest) - cross-env + dotenv pour portabilité Windows/Linux - vite.config.ts proxy dynamique via BACKEND_PORT env var Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
58 lines
1.6 KiB
TypeScript
58 lines
1.6 KiB
TypeScript
import { defineConfig, devices } from '@playwright/test';
|
|
import dotenv from 'dotenv';
|
|
|
|
dotenv.config({ path: '.env.test' });
|
|
|
|
const FRONTEND_PORT = process.env.E2E_FRONTEND_PORT ?? '5174';
|
|
const BACKEND_PORT = process.env.E2E_BACKEND_PORT ?? '3002';
|
|
const E2E_DB_URL = process.env.E2E_DATABASE_URL ?? '';
|
|
|
|
if (!E2E_DB_URL) {
|
|
throw new Error('[Playwright] E2E_DATABASE_URL missing. Check .env.test at project root.');
|
|
}
|
|
|
|
export default defineConfig({
|
|
testDir: './tests/e2e',
|
|
testMatch: '**/*.spec.ts',
|
|
timeout: 30000,
|
|
retries: 1,
|
|
workers: 1,
|
|
projects: [
|
|
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
|
|
],
|
|
use: {
|
|
baseURL: `http://localhost:${FRONTEND_PORT}`,
|
|
headless: true,
|
|
screenshot: 'only-on-failure',
|
|
trace: 'on-first-retry',
|
|
actionTimeout: 10000,
|
|
navigationTimeout: 15000,
|
|
},
|
|
globalSetup: './tests/e2e/global-setup.ts',
|
|
globalTeardown: './tests/e2e/global-teardown.ts',
|
|
reporter: [
|
|
['list'],
|
|
['html', { open: 'never', outputFolder: 'playwright-report' }],
|
|
],
|
|
outputDir: 'test-results',
|
|
|
|
webServer: [
|
|
{
|
|
command: `cross-env DATABASE_URL="${E2E_DB_URL}" PORT=${BACKEND_PORT} JWT_SECRET=test_jwt_secret_2026_only_for_e2e SMTP_DRY_RUN=true npm run dev`,
|
|
port: parseInt(BACKEND_PORT),
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 90000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
},
|
|
{
|
|
command: `cross-env BACKEND_PORT=${BACKEND_PORT} npm --prefix frontend run dev -- --port ${FRONTEND_PORT}`,
|
|
port: parseInt(FRONTEND_PORT),
|
|
reuseExistingServer: !process.env.CI,
|
|
timeout: 30000,
|
|
stdout: 'pipe',
|
|
stderr: 'pipe',
|
|
},
|
|
],
|
|
});
|