clerk-testing

por clerk

Utilitários de teste E2E para fluxos de autenticação do Clerk no Playwright e Cypress. Suporta ambos os frameworks Playwright e Cypress com padrões de configuração específicos (globalSetup para Playwright, comandos personalizados para Cypress). Fornece as utilidades clerkSetup() e setupClerkTestingToken() para inicializar ambientes de teste e ignorar a detecção de bots. Inclui persistência de storageState para reutilizar sessões autenticadas entre testes, reduzindo o tempo de execução. Requer chaves de API de teste ( 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

Mais skills de clerk

clerk-monorepo
clerk
Trabalhe efetivamente no monorepo do SDK clerk/javascript. Use ao configurar o repositório, compilar / testar / executar um pacote, decidindo qual dos @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
Autor e usa máquinas de estado Mosaic. Use quando o usuário estiver escrevendo uma máquina de estado com createMachine, modelando um fluxo de múltiplas etapas, conectando uma máquina ao 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
Padrões Astro com Clerk — middleware, páginas SSR, componentes de ilha, rotas de API, renderização estática vs SSR. Dispara em: astro clerk, clerk astro middleware,…
official
clerk-backend-api
clerk
Explorador e executor da API REST do Clerk Backend. Navegue por tags, inspecione esquemas de endpoints e execute requisições autenticadas. Use ao listar usuários, gerenciar…
official
clerk-chrome-extension-patterns
clerk
Chrome Extension auth with @clerk/chrome-extension -- popup/sidepanel setup, syncHost for OAuth/SAML via web app, createClerkClient for service workers and…
official
clerk-cli
clerk
Operate the Clerk CLI (`clerk` binary) for authentication, user/org/session management, impersonation, local webhook testing, deploy verification, instance…
official