
Description
E2E testing for Clerk apps. Use with Playwright or Cypress for auth flow tests.
SKILL.md
Testing
Decision Tree
Mental Model
Test auth = isolated session state. Each test needs fresh auth context.
clerkSetup()initializes test environmentsetupClerkTestingToken()bypasses bot detectionstorageStatepersists auth between tests for speed
Workflow
- Identify test framework (Playwright or Cypress)
- WebFetch the appropriate URL from decision tree above
- Follow official setup instructions
- Use
pk_test_*andsk_test_*keys only
Best Practices
- Use
setupClerkTestingToken()before navigating to auth pages - Use test API keys:
pk_test_xxx,sk_test_xxx - Save auth state with
storageStatefor faster tests - Use
page.waitForSelector('[data-clerk-component]')for Clerk UI
Anti-Patterns
| Pattern | Problem | Fix |
|---|---|---|
| Production keys in tests | Security risk | Use pk_test_* keys |
No setupClerkTestingToken() | Auth fails | Call before navigation |
| UI-based sign-in every test | Slow tests | Use storageState |
Framework-Specific
Playwright: Use globalSetup for auth state
Cypress: Add addClerkCommands({ Cypress, cy }) to support file
See Also
clerk-setup- Install Clerk before adding testsclerk-nextjs-patterns- Next.js patterns being tested- Demo Repo
More skills from the skills repository
View all 20 skillsclerk
route Clerk authentication requests
Jul 18AuthenticationClerkMobileWeb Developmentclerk-android
implement Clerk auth for native Android apps
Apr 10AndroidClerkKotlinMobileclerk-astro-patterns
implement Clerk auth in Astro apps
Apr 7AstroAuthenticationClerkFrontend +1clerk-backend-api
execute Clerk Backend API requests
Apr 10API DevelopmentAuthenticationBackendClerk +1clerk-billing
manage subscriptions with Clerk Billing
Apr 29AuthenticationClerkFrontendPayments +1clerk-chrome-extension-patterns
implement Clerk auth in Chrome Extensions
Apr 7AuthClerkFrontendOAuth +1
More from Clerk
View publisherclerk-cli
manage Clerk authentication and instances via CLI
skills
Jul 18API DevelopmentAuthenticationClerkCLI +2clerk-custom-ui
customize Clerk UI and auth flows
skills
Apr 10AuthenticationBrandingClerkDesign +1clerk-expo
implement Clerk authentication in Expo apps
skills
May 19AuthenticationClerkExpoFrontend +2clerk-nextjs-patterns
implement advanced Next.js patterns with Clerk
skills
Apr 10ClerkFrontendNext.jsPerformanceclerk-nuxt-patterns
implement Clerk auth in Nuxt 3 apps
skills
Apr 7AuthenticationBackendClerkFrontend +1clerk-orgs
manage Clerk Organizations for B2B SaaS
skills
Apr 10ClerkMulti-TenantRBACSaaS