Skip to content

Commit e19353e

Browse files
fix: restore dev stack after e2e tests to prevent env contamination
The e2e script mutates running containers in-place with test env config but never restores them. This leaves nginx on port 8080 with APP_ENV=test after tests complete. Add an EXIT trap that runs `docker compose up -d` (without the e2e override) to recreate containers with dev defaults.
1 parent bf6867d commit e19353e

1 file changed

Lines changed: 17 additions & 1 deletion

File tree

.mise/tasks/tests/e2e.sh

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,14 @@ echo "End-to-end tests (Playwright)"
1313
echo "BASE_URL=${BASE_URL}"
1414
echo
1515

16+
restore_dev_stack() {
17+
echo ""
18+
echo "Restoring dev stack (docker compose up -d)..."
19+
docker compose up -d
20+
}
21+
1622
if [ "${NO_START}" != "true" ]; then
23+
trap restore_dev_stack EXIT
1724
echo "Starting stack with e2e override..."
1825
docker compose $COMPOSE_FILES up -d
1926
echo "Waiting for MariaDB..."
@@ -48,6 +55,15 @@ echo "Installing Playwright dependencies (if needed)..."
4855
(cd tests/End2End && npx playwright install chromium 2>/dev/null || true)
4956

5057
echo "Running Playwright tests..."
58+
set +e
5159
(cd tests/End2End && BASE_URL="$BASE_URL" npx playwright test)
60+
PLAYWRIGHT_EXIT=$?
61+
set -e
62+
63+
if [ $PLAYWRIGHT_EXIT -eq 0 ]; then
64+
echo "E2E tests completed!"
65+
else
66+
echo "E2E tests failed (exit code $PLAYWRIGHT_EXIT)."
67+
fi
5268

53-
echo "E2E tests completed!"
69+
exit $PLAYWRIGHT_EXIT

0 commit comments

Comments
 (0)