Skip to content

Commit 579e44c

Browse files
committed
fix(ci): use node require.resolve to find playwright CLI path
This ensures the script works correctly in CI environments where node_modules structure might differ, by using Node's own module resolution to find the Playwright CLI path.
1 parent 91b8480 commit 579e44c

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

frontend/run-e2e-tests.sh

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -40,28 +40,24 @@ PASSED_TESTS=0
4040
FAILED_TESTS=0
4141
FAILED_FILES=()
4242

43-
# Ensure we're in the frontend directory
43+
# Ensure we're in the frontend directory (where the script is located)
4444
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
4545
cd "$SCRIPT_DIR"
4646

4747
# Verify node_modules exists
4848
if [ ! -d "node_modules" ]; then
49-
echo -e "${RED}Error: node_modules not found. Run 'bun install' first.${NC}"
49+
echo -e "${RED}Error: node_modules not found in $(pwd). Run 'bun install' first.${NC}"
5050
exit 1
5151
fi
5252

53-
# Verify @playwright/test is installed
54-
if [ ! -d "node_modules/@playwright/test" ]; then
55-
echo -e "${RED}Error: @playwright/test not found. Run 'bun install' first.${NC}"
56-
exit 1
57-
fi
58-
59-
# Use node to run the playwright CLI script directly from the local installation
60-
# This ensures proper module resolution in CI environments
61-
PLAYWRIGHT_CLI="node_modules/@playwright/test/cli.js"
53+
# Use node's require.resolve to find the actual path to the Playwright CLI
54+
# This works even if node_modules structure is different (e.g., with Bun)
55+
PLAYWRIGHT_CLI=$(node -e "console.log(require.resolve('@playwright/test/cli.js'))" 2>/dev/null || echo "")
6256

63-
if [ ! -f "$PLAYWRIGHT_CLI" ]; then
64-
echo -e "${RED}Error: Playwright CLI not found. Run 'bun install' first.${NC}"
57+
if [ -z "$PLAYWRIGHT_CLI" ] || [ ! -f "$PLAYWRIGHT_CLI" ]; then
58+
echo -e "${RED}Error: Could not find @playwright/test. Run 'bun install' first.${NC}"
59+
echo "Current directory: $(pwd)"
60+
echo "node_modules exists: $([ -d "node_modules" ] && echo "yes" || echo "no")"
6561
exit 1
6662
fi
6763

0 commit comments

Comments
 (0)