Enhance Playwright E2E configuration by adding ignored files and adjusting authentication setup. Ensure proper handling of storage state in CI environments.

This commit is contained in:
2026-04-24 09:22:36 -05:00
parent a77a05ea5b
commit 59c805b48c
3 changed files with 21 additions and 4 deletions

6
frontend/.gitignore vendored
View File

@@ -1,4 +1,10 @@
test-results
# Playwright E2E: no versionar sesión, reportes ni estado compartido generado
e2e/.auth/user.json
e2e/.e2e-*.json
playwright-report/
blob-report/
node_modules
# Output

View File

@@ -1,4 +1,5 @@
import { test as setup } from '@playwright/test'
import { mkdirSync } from 'node:fs'
import { fileURLToPath } from 'url'
import path from 'path'
@@ -11,5 +12,6 @@ setup('autenticacion', async ({ page }) => {
await page.locator('input[id^="password"]').fill('demo123')
await page.click('button[type="submit"]')
await page.waitForURL(/dashboard/, { timeout: 60000 })
mkdirSync(path.dirname(authFile), { recursive: true })
await page.context().storageState({ path: authFile })
})

View File

@@ -4,24 +4,33 @@ import path from '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: 'http://localhost:5173',
headless: false,
storageState: path.join(__dirname, 'e2e/.auth/user.json')
// Sin display en agentes de integración: obligatorio headless
headless: inCI ? true : false
},
workers: 1,
testDir: 'e2e',
projects: [
{
name: 'setup',
testMatch: '**/auth.setup.ts'
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']
testIgnore: ['**/auth.setup.ts', '**/demo.test.ts'],
use: { storageState: authStatePath }
}
]
});