towerops/e2e/playwright.config.ts
Graham McIntire 8fd18b08ab
fix: run auth tests unauthenticated, deploy on ExUnit pass only
Playwright config:
- Added chromium-unauthenticated project for registration/login tests
- These tests run without saved auth state (as intended)
- Other tests continue using authenticated state

Workflow:
- build-and-deploy now only requires test-exunit to pass
- test-e2e runs in parallel but doesn't block deployment
- Allows faster deployments while e2e tests provide additional validation
2026-03-08 13:46:34 -05:00

116 lines
3.1 KiB
TypeScript

import { defineConfig, devices } from '@playwright/test';
import * as dotenv from 'dotenv';
/**
* Read environment variables from file.
* https://github.com/motdotla/dotenv
*/
dotenv.config();
/**
* See https://playwright.dev/docs/test-configuration.
*/
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
/* Maximum time one test can run */
timeout: 30 * 1000,
/* Maximum time for entire test run */
globalTimeout: 5 * 60 * 1000,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: process.env.CI
? [['list']]
: [['list'], ['html', { open: 'never' }]],
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
use: {
/* Base URL to use in actions like `await page.goto('/')`. */
baseURL: process.env.BASE_URL || 'http://localhost:4000',
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
/* Screenshot on failure */
screenshot: 'only-on-failure',
/* Video on failure */
video: 'retain-on-failure',
/* Run in headless mode by default */
headless: true,
},
/* Configure projects for major browsers */
projects: [
// Setup project - runs first to authenticate
{
name: 'setup',
testMatch: /.*\.setup\.ts/,
},
// Unauthenticated tests (registration, login flows, etc.)
{
name: 'chromium-unauthenticated',
use: {
...devices['Desktop Chrome'],
// No storageState - runs without authentication
},
testMatch: /tests\/(auth-flows|registration)\.spec\.ts/,
},
{
name: 'chromium',
use: {
...devices['Desktop Chrome'],
// Use prepared auth state
storageState: 'tests/.auth/user.json',
},
testIgnore: /tests\/(auth-flows|registration)\.spec\.ts/,
dependencies: ['setup'],
},
{
name: 'firefox',
use: {
...devices['Desktop Firefox'],
storageState: 'tests/.auth/user.json',
},
testIgnore: /tests\/(auth-flows|registration)\.spec\.ts/,
dependencies: ['setup'],
},
{
name: 'webkit',
use: {
...devices['Desktop Safari'],
storageState: 'tests/.auth/user.json',
},
testIgnore: /tests\/(auth-flows|registration)\.spec\.ts/,
dependencies: ['setup'],
},
/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: {
// ...devices['Pixel 5'],
// storageState: 'tests/.auth/user.json',
// },
// dependencies: ['setup'],
// },
],
/* Run your local dev server before starting the tests */
// webServer: {
// command: 'mix phx.server',
// url: 'http://localhost:4000',
// reuseExistingServer: !process.env.CI,
// cwd: '..',
// },
});