import { test as setup, expect } from '@playwright/test'; import path from 'node:path'; const authFile = path.join(__dirname, '../playwright/.auth/user.json'); setup('authenticate', async ({ page }) => { const user = process.env.E2E_USER; const password = process.env.E2E_PASSWORD; if (!user || !password) { throw new Error('Set E2E_USER and E2E_PASSWORD before running authentication setup.'); } await page.goto('/login'); await page.getByLabel('Email').fill(user); await page.getByLabel('Password').fill(password); await page.getByRole('button', { name: 'Sign in' }).click(); await expect(page.getByRole('heading', { name: 'Dashboard' })).toBeVisible(); await page.context().storageState({ path: authFile }); });