clerk-testing

oleh clerk

Pengujian E2E untuk aplikasi Clerk. Gunakan dengan Playwright atau Cypress untuk pengujian alur autentikasi.

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

Lebih banyak skill dari clerk

clerk-monorepo
clerk
Bekerja secara efektif di monorepo clerk/javascript SDK. Gunakan saat menyiapkan repo, membangun/menguji/menjalankan sebuah paket, memutuskan mana dari @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
Menulis dan menggunakan state machine Mosaic. Gunakan saat pengguna menulis state machine dengan createMachine, memodelkan alur multi-langkah, menghubungkan machine ke React…
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
Pola Astro dengan Clerk — middleware, halaman SSR, komponen island, rute API, rendering statis vs SSR. Dipicu oleh: astro clerk, clerk astro middleware,…
official
clerk-backend-api
clerk
Penjelajah dan eksekutor REST API Backend Clerk. Jelajahi tag, periksa skema endpoint, dan jalankan permintaan terautentikasi. Gunakan saat mendaftarkan pengguna, mengelola…
official
clerk-chrome-extension-patterns
clerk
Autentikasi Chrome Extension dengan @clerk/chrome-extension -- pengaturan popup/sidepanel, syncHost untuk OAuth/SAML melalui aplikasi web, createClerkClient untuk service workers dan…
official
clerk-cli
clerk
Operate the Clerk CLI (`clerk` binary) for authentication, user/org/session management, impersonation, local webhook testing, deploy verification, instance…
official