clerk-testing

von clerk

E2E-Testhilfsprogramme für Clerk-Authentifizierungsabläufe in Playwright und Cypress. Unterstützt sowohl Playwright- als auch Cypress-Frameworks mit frameworkspezifischen Einrichtungsmustern (globalSetup für Playwright, benutzerdefinierte Befehle für Cypress). Bietet die Hilfsprogramme clerkSetup() und setupClerkTestingToken() zur Initialisierung von Testumgebungen und Umgehung der Bot-Erkennung. Enthält Speicherstatus-Persistenz zur Wiederverwendung authentifizierter Sitzungen über Tests hinweg, wodurch die Testausführungszeit reduziert wird. Erfordert Test-API-Schlüssel ( pk_test_* ,...

npx skills add https://github.com/clerk/skills --skill clerk-testing

Testing

Decision Tree

FrameworkDocumentation
Overviewhttps://clerk.com/docs/guides/development/testing/overview
Playwrighthttps://clerk.com/docs/guides/development/testing/playwright/overview
Cypresshttps://clerk.com/docs/guides/development/testing/cypress/overview

Mental Model

Test auth = isolated session state. Each test needs fresh auth context.

  • clerkSetup() initializes test environment
  • setupClerkTestingToken() bypasses bot detection
  • storageState persists auth between tests for speed

Workflow

  1. Identify test framework (Playwright or Cypress)
  2. WebFetch the appropriate URL from decision tree above
  3. Follow official setup instructions
  4. Use pk_test_* and sk_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 storageState for faster tests
  • Use page.waitForSelector('[data-clerk-component]') for Clerk UI

Anti-Patterns

PatternProblemFix
Production keys in testsSecurity riskUse pk_test_* keys
No setupClerkTestingToken()Auth failsCall before navigation
UI-based sign-in every testSlow testsUse 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 tests
  • clerk-nextjs-patterns - Next.js patterns being tested
  • Demo Repo

Mehr Skills von clerk

clerk-monorepo
clerk
Work effectively in the clerk/javascript SDK monorepo. Use when setting up the repo, building / testing / running a package, deciding which of the @clerk/*…
official
mosaic
clerk
Work on Mosaic UI: styling a component with slot recipes (`defineSlotRecipe` / `useRecipe` / slots / variants), or building a flow — authoring a state machine…
official
mosaic-machine
clerk
Author und Nutzung von Mosaic-Zustandsmaschinen. Verwenden, wenn der Benutzer eine Zustandsmaschine mit createMachine schreibt, einen mehrstufigen Ablauf modelliert, eine Maschine mit React verbindet …
official
clerk-android
clerk
Implement Clerk authentication for native Android apps using Kotlin and Jetpack Compose with clerk-android source-guided patterns. Use for prebuilt…
official
clerk-astro-patterns
clerk
Astro-Muster mit Clerk — Middleware, SSR-Seiten, Island-Komponenten, API-Routen, statisches vs. SSR-Rendering. Ausgelöst durch: astro clerk, clerk astro middleware,…
official
clerk-backend-api
clerk
Clerk Backend REST API explorer and executor. Browse tags, inspect endpoint schemas, and execute authenticated requests. Use when listing users, managing…
official
clerk-chrome-extension-patterns
clerk
Chrome Extension-Authentifizierung mit @clerk/chrome-extension -- Popup/Sidepanel-Einrichtung, syncHost für OAuth/SAML über Web-App, createClerkClient für Service Worker und…
official
clerk-cli
clerk
Operate the Clerk CLI (`clerk` binary) for authentication, user/org/session management, impersonation, local webhook testing, deploy verification, instance…
official