clerk-testing

작성자: clerk

Clerk 인증 흐름을 위한 Playwright 및 Cypress E2E 테스트 유틸리티입니다. Playwright와 Cypress 프레임워크를 모두 지원하며, 각 프레임워크에 맞는 설정 패턴(Playwright의 globalSetup, Cypress의 커스텀 명령어)을 제공합니다. 테스트 환경을 초기화하고 봇 탐지를 우회하기 위해 clerkSetup()과 setupClerkTestingToken() 유틸리티를 제공합니다. 인증된 세션을 테스트 간에 재사용하여 테스트 실행 시간을 줄이는 storageState 지속성을 포함합니다. 테스트 API 키(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 development-instance keys only (pk_test_* / sk_test_*). If the project has no keys yet, npx clerk@latest init (the Clerk CLI; see clerk-setup) creates a Clerk application and writes development-instance keys to the env file. No Clerk account or Dashboard visit is needed.

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

clerk의 다른 스킬

mosaic
clerk
Work on Mosaic UI: styling a component with slot recipes (`defineSlotRecipe` / `useRecipe` / slots / variants), or building a flow — authoring a state machine…
clerk-billing
clerk
구독 관리를 위한 Clerk Billing - Clerk의 PricingTable을 렌더링합니다.
clerk-nextjs-patterns
clerk
Clerk를 사용한 인증, 미들웨어, 서버 액션, 사용자 범위 캐싱을 위한 고급 Next.js 패턴. 서버 측 await auth()와 클라이언트 측 useAuth() 훅을 구분하며, 이 둘을 혼용하는 것은 흔한 치명적 실수입니다. 미들웨어 전략(퍼블릭 우선 vs 보호 우선), API 라우트 보호, 적절한 HTTP 상태 코드(401 vs 403)를 다룹니다. unstable_cache를 사용한 사용자 범위 캐싱 패턴과 승인되지 않은 변이로부터 서버 액션을 보호하는 방법을 포함합니다. Core 2 호환성을 제공합니다...
clerk-expo-patterns
clerk
Expo / React Native 패턴과 Clerk — SecureStore 토큰 캐시, OAuth
changesets
clerk
Create or refresh a `.changeset/<slug>.md` for the current branch, or report that none is required. Triggers on "/changesets create", "add a changeset",…
clerk
clerk
clerk 바이너리는 Clerk의 백엔드 API 및 플랫폼 API에 대한 사전 인증된 게이트웨이이며, 프로젝트 수준 도구(인증, 링킹, 환경 변수 가져오기, 인스턴스 구성)를 포함합니다. 사용자가 Clerk 리소스와 관련된 질문을 하면, 직접 curl을 작성하는 대신 먼저 clerk을 사용하세요.
clerk-cli
clerk
clerk 바이너리는 Clerk의 백엔드 API 및 플랫폼 API에 대한 사전 인증된 게이트웨이로, 프로젝트 수준 도구(인증, 링킹, 환경 변수 가져오기, 인스턴스 구성)를 포함합니다. 사용자가 Clerk 리소스와 관련된 질문을 하면, 수동으로 curl을 작성하는 대신 먼저 clerk을 사용하세요.
clerk-astro-patterns
clerk
Clerk을 사용한 Astro 패턴 — 미들웨어, SSR 페이지, 아일랜드 컴포넌트