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:
6
frontend/.gitignore
vendored
6
frontend/.gitignore
vendored
@@ -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
|
||||
|
||||
@@ -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 })
|
||||
})
|
||||
@@ -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 }
|
||||
}
|
||||
]
|
||||
});
|
||||
Reference in New Issue
Block a user