-
Notifications
You must be signed in to change notification settings - Fork 435
Open
Description
Description
clerkSetup() from @clerk/testing/playwright requires the env var CLERK_PUBLISHABLE_KEY to be set. However, the standard Next.js convention (and what @clerk/nextjs uses) is NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY. This forces developers to pass both env vars explicitly when running tests.
Environment
@clerk/testing: 1.13.36@clerk/nextjs: latest@playwright/test: 1.57.0- Next.js: 15.4.11
Reproduction
- Configure a Next.js app with Clerk using
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEYin.env.local(standard setup) - Set up Playwright with
@clerk/testing - Run tests without explicitly setting
CLERK_PUBLISHABLE_KEY clerkSetup()fails because it only looks forCLERK_PUBLISHABLE_KEY
Workaround
Must pass both env vars when running tests:
CLERK_PUBLISHABLE_KEY=$NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY \
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxx \
npx playwright testExpected Behavior
clerkSetup() should fall back to NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY if CLERK_PUBLISHABLE_KEY is not set, since that's the standard env var name used in Next.js projects with @clerk/nextjs.
Suggested Fix
In the clerkSetup() initialization:
const publishableKey = process.env.CLERK_PUBLISHABLE_KEY
?? process.env.NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY;Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels