clerk-testing

bởi clerk

E2E testing for Clerk apps. Use with Playwright or Cypress for auth flow tests.

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

Thêm skills từ clerk

clerk-monorepo
clerk
Làm việc hiệu quả trong kho monorepo của clerk/javascript SDK. Sử dụng khi thiết lập kho, xây dựng / kiểm thử / chạy một package, quyết định gói nào trong số @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
Tác giả và sử dụng máy trạng thái Mosaic. Sử dụng khi người dùng đang viết máy trạng thái với createMachine, mô hình hóa luồng nhiều bước, kết nối máy với 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
Các mẫu Astro với Clerk — middleware, trang SSR, thành phần island, route API, render tĩnh so với SSR. Kích hoạt khi: astro clerk, clerk astro middleware,…
official
clerk-backend-api
clerk
Trình khám phá và thực thi REST API backend của Clerk. Duyệt các thẻ, kiểm tra lược đồ endpoint, và thực thi các yêu cầu đã xác thực. Sử dụng khi liệt kê người dùng, quản lý…
official
clerk-chrome-extension-patterns
clerk
Xác thực Chrome Extension với @clerk/chrome-extension -- thiết lập popup/sidepanel, syncHost cho OAuth/SAML qua ứng dụng web, createClerkClient cho service workers và…
official
clerk-cli
clerk
Operate the Clerk CLI (`clerk` binary) for authentication, user/org/session management, impersonation, local webhook testing, deploy verification, instance…
official