Features: - Device presets (desktop, mobile, tablet, obs-overlay, all, electron) - Auth setup projects with storage state management - Cluster mode for Docker nginx multi-app routing - Multiple reporters (list, html, junit, github) - WebServer configuration for dev server management - Enhanced helpers: file upload, platform, performance, accessibility, storage - GitLab CI templates for package and consumers - Docker templates: Electron, web-only, cluster compose Breaking changes from 1.0: - Enhanced PlaywrightConfigOptions interface with new options - Exported commonDevices for device configuration access 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
66 lines
2.4 KiB
Bash
Executable file
66 lines
2.4 KiB
Bash
Executable file
#!/bin/bash
|
|
# Initialize E2E testing infrastructure in a project
|
|
#
|
|
# Usage: npx @transquinnftw/playwright-e2e-docker init
|
|
# or: ./scripts/init-e2e.sh /path/to/project
|
|
|
|
set -e
|
|
|
|
PROJECT_DIR="${1:-.}"
|
|
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
|
|
TEMPLATE_DIR="$SCRIPT_DIR/../templates"
|
|
|
|
echo "Initializing Playwright E2E Docker infrastructure..."
|
|
|
|
# Create e2e directory
|
|
mkdir -p "$PROJECT_DIR/e2e"
|
|
mkdir -p "$PROJECT_DIR/e2e/mock-service"
|
|
mkdir -p "$PROJECT_DIR/test-results"
|
|
|
|
# Copy templates
|
|
echo "Copying Docker templates..."
|
|
cp "$TEMPLATE_DIR/Dockerfile" "$PROJECT_DIR/e2e/"
|
|
cp "$TEMPLATE_DIR/docker-compose.yml" "$PROJECT_DIR/e2e/"
|
|
cp "$TEMPLATE_DIR/mock-service.Dockerfile" "$PROJECT_DIR/e2e/"
|
|
|
|
echo "Copying mock service template..."
|
|
cp "$TEMPLATE_DIR/mock-service/app.py" "$PROJECT_DIR/e2e/mock-service/"
|
|
cp "$TEMPLATE_DIR/mock-service/__init__.py" "$PROJECT_DIR/e2e/mock-service/"
|
|
|
|
echo "Copying test templates..."
|
|
cp "$TEMPLATE_DIR/electron.ts" "$PROJECT_DIR/e2e/"
|
|
cp "$TEMPLATE_DIR/example.e2e.ts" "$PROJECT_DIR/e2e/"
|
|
|
|
# Check if playwright.config.ts exists
|
|
if [ ! -f "$PROJECT_DIR/playwright.config.ts" ]; then
|
|
echo "Copying Playwright config..."
|
|
cp "$TEMPLATE_DIR/playwright.config.ts" "$PROJECT_DIR/"
|
|
else
|
|
echo "playwright.config.ts already exists, skipping..."
|
|
fi
|
|
|
|
# Add .gitignore entries
|
|
echo "Updating .gitignore..."
|
|
if [ -f "$PROJECT_DIR/.gitignore" ]; then
|
|
if ! grep -q "test-results" "$PROJECT_DIR/.gitignore"; then
|
|
echo -e "\n# E2E test artifacts\ntest-results/\nplaywright-report/" >> "$PROJECT_DIR/.gitignore"
|
|
fi
|
|
else
|
|
echo -e "# E2E test artifacts\ntest-results/\nplaywright-report/" > "$PROJECT_DIR/.gitignore"
|
|
fi
|
|
|
|
echo ""
|
|
echo "E2E infrastructure initialized!"
|
|
echo ""
|
|
echo "Next steps:"
|
|
echo " 1. Add @transquinnftw/playwright-e2e-docker and @playwright/test to devDependencies"
|
|
echo " 2. Customize e2e/docker-compose.yml for your backend services"
|
|
echo " 3. Customize e2e/mock-service/app.py for your API"
|
|
echo " 4. Update e2e/electron.ts with your app's main path"
|
|
echo " 5. Add npm scripts to package.json:"
|
|
echo ""
|
|
echo ' "test:e2e": "pnpm test:e2e:docker",'
|
|
echo ' "test:e2e:docker": "docker build -f e2e/Dockerfile -t app-e2e . && docker run --rm -v $(pwd)/test-results:/app/test-results app-e2e",'
|
|
echo ' "test:e2e:full": "docker compose -f e2e/docker-compose.yml up --build --abort-on-container-exit --exit-code-from e2e-tests",'
|
|
echo ' "test:e2e:down": "docker compose -f e2e/docker-compose.yml down -v"'
|
|
echo ""
|