Fingers crossed for working CI e2e tests
This commit is contained in:
41
scripts/update-e2e-snapshots.sh
Executable file
41
scripts/update-e2e-snapshots.sh
Executable file
@@ -0,0 +1,41 @@
|
||||
#!/usr/bin/env bash
|
||||
# Regenerate Playwright visual regression snapshots.
|
||||
# - When Docker is available: runs in the same image as CI (Playwright Noble) for a CI-accurate baseline.
|
||||
# - When Docker is not available (e.g. devcontainer): runs Playwright in the current environment;
|
||||
# the Linux snapshot may still differ slightly from CI — if CI fails, run this script on the host with Docker.
|
||||
set -e
|
||||
|
||||
SCRIPT_DIR="${BASH_SOURCE%/*}"
|
||||
PROJECT_ROOT="${SCRIPT_DIR}/.."
|
||||
cd "$PROJECT_ROOT"
|
||||
|
||||
if command -v docker >/dev/null 2>&1; then
|
||||
PLAYWRIGHT_IMAGE="${PLAYWRIGHT_IMAGE:-mcr.microsoft.com/playwright:v1.58.0-noble}"
|
||||
echo "Using Docker image: $PLAYWRIGHT_IMAGE (same as CI)"
|
||||
echo "Project root: $PROJECT_ROOT"
|
||||
echo ""
|
||||
|
||||
docker run --rm \
|
||||
-v "$PROJECT_ROOT:/app" -w /app \
|
||||
-e CI=1 \
|
||||
"$PLAYWRIGHT_IMAGE" \
|
||||
bash -c '
|
||||
corepack enable && corepack prepare pnpm@10.28.2 --activate
|
||||
pnpm install --frozen-lockfile || pnpm install
|
||||
pnpm run build
|
||||
npx serve dist -p 4173 &
|
||||
sleep 2
|
||||
pnpm exec playwright test --update-snapshots
|
||||
'
|
||||
else
|
||||
echo "Docker not found — updating snapshots in the current environment."
|
||||
echo "If CI later fails with a snapshot mismatch, run this script on a host with Docker for a CI-accurate baseline."
|
||||
echo ""
|
||||
|
||||
# Unset CI so Playwright config starts the preview server
|
||||
unset CI
|
||||
pnpm exec playwright test --update-snapshots
|
||||
fi
|
||||
|
||||
echo ""
|
||||
echo "Snapshots updated. Commit the changed files under tests/visual.spec.ts-snapshots/ if needed."
|
||||
Reference in New Issue
Block a user