- Added a new 'E2E (docker compose + Playwright)' stage in the Jenkinsfile to run end-to-end tests using Docker Compose and Playwright. - Updated the 'Test frontend' stage to utilize the Playwright test image and improved error handling for missing files. - Modified Playwright configuration to use an environment variable for the base URL, enhancing flexibility in CI environments. - Expanded TypeScript configuration to include additional test and configuration files for better type checking.
36 lines
1.2 KiB
TypeScript
36 lines
1.2 KiB
TypeScript
import { defineConfig } from '@playwright/test';
|
|
import { fileURLToPath } from 'node:url';
|
|
import path from 'node:path';
|
|
|
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
|
|
const authStatePath = path.join(__dirname, 'e2e/.auth/user.json');
|
|
/** GitHub/Gitea/GitLab suelen exportar CI=true; Jenkins no siempre, pero define JENKINS_URL. */
|
|
const inCI = process.env.CI === 'true' || Boolean(process.env.JENKINS_URL);
|
|
|
|
export default defineConfig({
|
|
// En CI, falla si queda un .only; en local no
|
|
forbidOnly: inCI,
|
|
timeout: 60000,
|
|
use: {
|
|
baseURL: process.env.PLAYWRIGHT_TEST_BASE_URL || 'http://localhost:5173',
|
|
// Sin display en agentes de integración: obligatorio headless
|
|
headless: inCI ? true : false
|
|
},
|
|
workers: 1,
|
|
testDir: 'e2e',
|
|
projects: [
|
|
{
|
|
name: 'setup',
|
|
testMatch: '**/auth.setup.ts',
|
|
// Navegador limpio: user.json se genera aquí y no debe existir al primer run / en CI
|
|
use: { storageState: { cookies: [], origins: [] } }
|
|
},
|
|
{
|
|
name: 'tests',
|
|
dependencies: ['setup'],
|
|
testIgnore: ['**/auth.setup.ts', '**/demo.test.ts'],
|
|
use: { storageState: authStatePath }
|
|
}
|
|
]
|
|
}); |