Skip to content

Commit 4074fd7

Browse files
committed
fix(ci): ensure playwright binary is executed with node
The node_modules/.bin/playwright binary needs to be run with 'node' explicitly in CI environments to ensure proper module resolution. Adds debug output to show which method is being used.
1 parent dfa457d commit 4074fd7

File tree

1 file changed

+19
-11
lines changed

1 file changed

+19
-11
lines changed

frontend/run-e2e-tests.sh

Lines changed: 19 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,28 @@ if [ ! -d "node_modules" ]; then
5151
fi
5252

5353
# Try multiple methods to find and run Playwright
54-
# Method 1: Try node_modules/.bin/playwright (standard location)
54+
# Method 1: Use node to run node_modules/.bin/playwright (most reliable)
5555
if [ -f "node_modules/.bin/playwright" ]; then
56-
PLAYWRIGHT_CMD="node_modules/.bin/playwright"
57-
# Method 2: Try using bunx (Bun's package runner)
58-
elif command -v bunx >/dev/null 2>&1; then
59-
PLAYWRIGHT_CMD="bunx --bun playwright"
60-
# Method 3: Try using npx with explicit local package
61-
elif command -v npx >/dev/null 2>&1; then
62-
PLAYWRIGHT_CMD="npx --yes playwright"
63-
# Method 4: Try node require.resolve as fallback
64-
else
65-
PLAYWRIGHT_CLI=$(node -e "console.log(require.resolve('@playwright/test/cli.js'))" 2>/dev/null || echo "")
56+
PLAYWRIGHT_CMD="node node_modules/.bin/playwright"
57+
echo "Using: node node_modules/.bin/playwright"
58+
# Method 2: Try node require.resolve to find CLI directly
59+
elif PLAYWRIGHT_CLI=$(node -e "console.log(require.resolve('@playwright/test/cli.js'))" 2>/dev/null); then
6660
if [ -n "$PLAYWRIGHT_CLI" ] && [ -f "$PLAYWRIGHT_CLI" ]; then
6761
PLAYWRIGHT_CMD="node $PLAYWRIGHT_CLI"
62+
echo "Using: node $PLAYWRIGHT_CLI"
63+
fi
64+
fi
65+
66+
# Fallback methods if local installation not found
67+
if [ -z "$PLAYWRIGHT_CMD" ]; then
68+
# Method 3: Try using bunx (Bun's package runner)
69+
if command -v bunx >/dev/null 2>&1; then
70+
PLAYWRIGHT_CMD="bunx playwright"
71+
echo "Using: bunx playwright (fallback)"
72+
# Method 4: Try using npx as last resort
73+
elif command -v npx >/dev/null 2>&1; then
74+
PLAYWRIGHT_CMD="npx playwright"
75+
echo "Using: npx playwright (fallback)"
6876
else
6977
echo -e "${RED}Error: Could not find Playwright. Run 'bun install' first.${NC}"
7078
echo "Current directory: $(pwd)"

0 commit comments

Comments
 (0)