Set up Playwright for browser testing
- Playwright config for local browsers (Firefox by default) and Docker Chrome - docker-compose.chrome.yml for browserless/chrome container (arm64) - 4 connectivity smoke tests (home, contact, blog pages) - 3 auth tests (redirect, login, logout) with auth helpers - Custom fixtures with remote CDP connect support - Shell scripts for start/stop/full Docker Chrome workflow - Makefile targets: playwright, playwright-docker, playwright-full
This commit is contained in:
@@ -28,6 +28,70 @@ test: deps compile
|
||||
format:
|
||||
$(MISE_EXEC) mix format
|
||||
|
||||
# =============================================================================
|
||||
# Playwright e2e browser tests
|
||||
# =============================================================================
|
||||
#
|
||||
# Requires the Phoenix dev server running on the default port (8056).
|
||||
# Set PLAYWRIGHT_BASE_URL to point at a different server/port.
|
||||
#
|
||||
# Available browsers (local):
|
||||
# PLAYWRIGHT_BROWSER=firefox (default — works on macOS 15)
|
||||
# PLAYWRIGHT_BROWSER=chromium (crashes on macOS 15, use Docker Chrome)
|
||||
# PLAYWRIGHT_BROWSER=webkit
|
||||
#
|
||||
# Docker Chrome (alternative):
|
||||
# 1. docker compose -f docker-compose.chrome.yml up -d
|
||||
# 2. PLAYWRIGHT_BROWSERS_PATH=assets/node_modules/playwright-core/.local-browsers \
|
||||
# npx playwright test --config=playwright.docker.config.ts
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
# Run Playwright e2e tests (default: local Firefox)
|
||||
# Usage: make playwright
|
||||
# PLAYWRIGHT_BROWSER=chromium make playwright
|
||||
playwright:
|
||||
cd assets && PLAYWRIGHT_BROWSERS_PATH=node_modules/playwright-core/.local-browsers npx playwright test --config=../playwright.config.ts
|
||||
|
||||
# Run a specific Playwright test file
|
||||
# Usage: make playwright-test test/e2e/smoke.spec.ts
|
||||
playwright-test:
|
||||
cd assets && PLAYWRIGHT_BROWSERS_PATH=node_modules/playwright-core/.local-browsers npx playwright test --config=../playwright.config.ts $(filter-out $@,$(MAKECMDGOALS))
|
||||
|
||||
# Run Playwright tests with UI mode (headed browser)
|
||||
playwright-ui:
|
||||
cd assets && PLAYWRIGHT_BROWSERS_PATH=node_modules/playwright-core/.local-browsers npx playwright test --config=../playwright.config.ts --ui
|
||||
|
||||
# Show last Playwright HTML report
|
||||
playwright-report:
|
||||
cd assets && npx playwright show-report
|
||||
|
||||
# Start Docker Chrome container for remote Playwright
|
||||
playwright-docker-start:
|
||||
docker compose -f docker-compose.chrome.yml up -d
|
||||
|
||||
# Stop Docker Chrome container
|
||||
playwright-docker-stop:
|
||||
docker compose -f docker-compose.chrome.yml down
|
||||
|
||||
# Run Playwright against Docker Chrome (container must be running)
|
||||
playwright-docker:
|
||||
cd assets && PLAYWRIGHT_BROWSERS_PATH=node_modules/playwright-core/.local-browsers npx playwright test --config=../playwright.docker.config.ts
|
||||
|
||||
# Run full end-to-end workflow: start Docker Chrome, run tests, stop container
|
||||
playwright-full: playwright-docker-start
|
||||
@echo "Waiting for Chrome to be ready..."
|
||||
@sleep 3
|
||||
cd assets && PLAYWRIGHT_BROWSERS_PATH=node_modules/playwright-core/.local-browsers npx playwright test --config=../playwright.docker.config.ts; \
|
||||
EXIT_CODE=$$?; \
|
||||
cd ..; \
|
||||
docker compose -f docker-compose.chrome.yml down; \
|
||||
exit $$EXIT_CODE
|
||||
|
||||
# =============================================================================
|
||||
# Static analysis
|
||||
# =============================================================================
|
||||
|
||||
# Run Credo static analysis
|
||||
credo:
|
||||
$(MISE_EXEC) mix credo --strict
|
||||
Reference in New Issue
Block a user