Skip to content

Commit eb69022

Browse files
jonphippsclaude
andcommitted
fix: resolve E2E server startup issues in pre-push hook
- Create dedicated playwright.config.pre-push.ts for pre-push testing - Fix Rspack module resolution panics by properly managing server lifecycle - Use manual server management with pnpm serve:all for built files - Add proper server readiness checks and cleanup - Reduce to essential browsers (Chromium, Firefox, Mobile) for pre-push - Remove CI=true flag that was causing serve:all to run prematurely This resolves the "No module found" Rspack panics and ensures E2E tests run against properly built and served files. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <[email protected]>
1 parent 32cf75a commit eb69022

File tree

2 files changed

+68
-14
lines changed

2 files changed

+68
-14
lines changed

.husky/pre-push-optimized

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -65,20 +65,32 @@ if [ "$BRANCH" = "main" ] || [ "$BRANCH" = "dev" ]; then
6565

6666
# 4. Only run E2E if portal is affected
6767
if echo "$AFFECTED_PROJECTS" | grep -q "portal"; then
68-
echo "🌐 Portal affected - running multi-browser E2E tests..."
69-
# Set CI=true to use serve:all (built files) instead of start:all (dev servers)
70-
echo "🧪 Testing on Chromium..."
71-
CI=true npx playwright test --project=chromium || {
72-
echo "⚠️ Chromium E2E tests failed but continuing"
73-
}
74-
echo "🧪 Testing on Firefox..."
75-
CI=true npx playwright test --project=firefox || {
76-
echo "⚠️ Firefox E2E tests failed but continuing"
77-
}
78-
echo "🧪 Testing on Mobile Chrome..."
79-
CI=true npx playwright test --project="Mobile Chrome" || {
80-
echo "⚠️ Mobile Chrome E2E tests failed but continuing"
81-
}
68+
echo "🌐 Portal affected - running E2E tests against built files..."
69+
70+
# Start servers for built files
71+
echo "🚀 Starting servers for built files..."
72+
pnpm serve:all &
73+
SERVER_PID=$!
74+
75+
# Wait for servers to be ready
76+
echo "⏳ Waiting for servers to start..."
77+
sleep 10
78+
79+
# Check if portal is accessible
80+
if curl -s http://localhost:3000 > /dev/null; then
81+
echo "✅ Servers ready, running E2E tests..."
82+
npx playwright test --config=playwright.config.pre-push.ts || {
83+
echo "⚠️ E2E tests failed but continuing (non-blocking for protected branches)"
84+
}
85+
else
86+
echo "❌ Servers failed to start, skipping E2E tests"
87+
fi
88+
89+
# Cleanup servers
90+
echo "🧹 Stopping servers..."
91+
kill $SERVER_PID 2>/dev/null || true
92+
pnpm stop:all || true
93+
8294
else
8395
echo "📝 Portal not affected - skipping E2E tests"
8496
fi

playwright.config.pre-push.ts

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import { defineConfig, devices } from '@playwright/test';
2+
3+
/**
4+
* Pre-push specific Playwright configuration
5+
* Tests against built files served via docusaurus serve
6+
*/
7+
export default defineConfig({
8+
testDir: './e2e',
9+
fullyParallel: false, // Sequential for pre-push reliability
10+
forbidOnly: true,
11+
retries: 1, // One retry for flaky tests
12+
workers: 1, // Single worker for stability
13+
reporter: [
14+
['list'],
15+
['json', { outputFile: 'test-results/e2e-pre-push-results.json' }]
16+
],
17+
use: {
18+
baseURL: 'http://localhost:3000',
19+
trace: 'on-first-retry',
20+
screenshot: 'only-on-failure',
21+
video: 'retain-on-failure',
22+
},
23+
24+
/* Test only essential browsers for pre-push */
25+
projects: [
26+
{
27+
name: 'chromium',
28+
use: { ...devices['Desktop Chrome'] },
29+
},
30+
{
31+
name: 'firefox',
32+
use: { ...devices['Desktop Firefox'] },
33+
},
34+
{
35+
name: 'mobile',
36+
use: { ...devices['Pixel 5'] },
37+
}
38+
],
39+
40+
/* No automatic server - we'll manage it manually in pre-push hook */
41+
// webServer: undefined,
42+
});

0 commit comments

Comments
 (0)