-
Notifications
You must be signed in to change notification settings - Fork 435
Open
Description
Description
When using @clerk/testing with Playwright and --workers=2 (or more), all tests fail with TimeoutError: page.waitForFunction: Timeout 15000ms exceeded at clerk.signIn(). With --workers=1, authentication works 100% reliably.
Environment
@clerk/testing: 1.13.36@clerk/nextjs: latest@playwright/test: 1.57.0- Next.js: 15.4.11
- OS: Windows 11 (also likely affects Linux/macOS)
- Auth strategy:
emailAddress
Reproduction
- Set up a Next.js app with Clerk authentication
- Create a Playwright fixture using
@clerk/testing:
import { clerkSetup, clerk } from "@clerk/testing/playwright";
// In fixture:
await clerk.signIn({
page,
emailAddress: testUser.email,
});- Run tests with
--workers=1→ all tests pass - Run tests with
--workers=2→ all tests fail
Error
TimeoutError: page.waitForFunction: Timeout 15000ms exceeded.
at loaded (node_modules/@clerk/testing/src/playwright/helpers.ts:100:14)
at Object.b (node_modules/@clerk/testing/src/playwright/helpers.ts:120:9)
The timeout occurs at the window.Clerk?.loaded === true && window.Clerk?.user !== null wait inside signIn().
Analysis
Each Playwright worker creates a separate browser instance. When 2+ workers call clerk.signIn() concurrently:
setupClerkTestingToken()injects the dev-browser token into each browser- Both browsers navigate and wait for
window.Clerk.loaded && window.Clerk.user - The wait times out on both workers
Possible causes:
- Clerk Backend API rate-limits concurrent testing token validations from the same publishable key
- ClerkJS client-side hydration conflicts between concurrent browser sessions
- The dev-browser token mechanism doesn't support multiple simultaneous sessions
Expected Behavior
@clerk/testing should support concurrent Playwright workers, or the documentation should explicitly state that --workers=1 is required.
Suggested Improvements
- Support parallel test users with isolated Clerk sessions
- Provide a testing mode that doesn't require live ClerkJS hydration (e.g., a static token that bypasses the
window.Clerk.loadedwait) - Document the
--workers=1limitation if concurrent sessions aren't supported
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels