Skip to content

Commit 49ea2da

Browse files
committed
test: add debug logging and bump CI workers to 4 for stress testing
1 parent 51d7a70 commit 49ea2da

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

integration/playwright.config.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,17 @@ import * as path from 'path';
77

88
config({ path: path.resolve(__dirname, '.env.local') });
99

10+
// Enable debug logging for @clerk/testing route handler
11+
process.env.CLERK_TESTING_DEBUG = '1';
12+
1013
export const common: PlaywrightTestConfig = {
1114
testDir: './tests',
1215
snapshotDir: './tests/snapshots',
1316
fullyParallel: true,
1417
forbidOnly: !!process.env.CI,
1518
retries: process.env.CI ? 5 : 0,
1619
maxFailures: process.env.CI ? 5 : undefined,
17-
workers: process.env.E2E_WORKERS ? Number(process.env.E2E_WORKERS) : process.env.CI ? '50%' : '70%',
20+
workers: process.env.E2E_WORKERS ? Number(process.env.E2E_WORKERS) : process.env.CI ? 4 : '70%',
1821
use: {
1922
actionTimeout: 10_000,
2023
navigationTimeout: 30_000,

packages/testing/src/playwright/setupClerkTestingToken.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl
4242
}
4343

4444
if (setupContexts.has(browserContext)) {
45+
if (process.env.CLERK_TESTING_DEBUG) {
46+
console.log('[Clerk Testing] Route handler already registered for this context, skipping duplicate setup');
47+
}
4548
return;
4649
}
4750
setupContexts.add(browserContext);
@@ -72,6 +75,11 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl
7275
if (RETRYABLE_STATUS_CODES.has(status)) {
7376
if (attempt < MAX_ROUTE_RETRIES) {
7477
const delay = BASE_DELAY_MS * Math.pow(2, attempt) + Math.random() * JITTER_MAX_MS;
78+
if (process.env.CLERK_TESTING_DEBUG) {
79+
console.log(
80+
`[Clerk Testing] FAPI returned ${status}, retrying (attempt ${attempt + 1}/${MAX_ROUTE_RETRIES}, delay ${Math.round(delay)}ms): ${route.request().url()}`,
81+
);
82+
}
7583
await new Promise(resolve => setTimeout(resolve, delay));
7684
continue;
7785
}
@@ -100,6 +108,12 @@ export const setupClerkTestingToken = async ({ context, options, page }: SetupCl
100108
} catch (error) {
101109
if (attempt < MAX_ROUTE_RETRIES) {
102110
const delay = BASE_DELAY_MS * Math.pow(2, attempt) + Math.random() * JITTER_MAX_MS;
111+
if (process.env.CLERK_TESTING_DEBUG) {
112+
console.log(
113+
`[Clerk Testing] FAPI request error, retrying (attempt ${attempt + 1}/${MAX_ROUTE_RETRIES}, delay ${Math.round(delay)}ms): ${route.request().url()}`,
114+
error,
115+
);
116+
}
103117
await new Promise(resolve => setTimeout(resolve, delay));
104118
continue;
105119
}

0 commit comments

Comments
 (0)