clerk/clerk-testing

Testes E2E para aplicativos Clerk. Use com Playwright ou Cypress para testes de fluxo de autenticação.

O que é clerk-testing?

Esta skill, `clerk/clerk-testing`, fornece toda a estrutura necessária para realizar testes end-to-end (E2E) em aplicações que utilizam Clerk para autenticação. Ela se integra perfeitamente com frameworks populares de testes como Playwright e Cypress, permitindo que desenvolvedores escrevam testes automatizados para fluxos de login, registro e logout de forma confiável e sem depender de serviços externos. A principal vantagem é a capacidade de simular estados de autenticação (usuários logados, não logados, etc.) através de helpers e configurações específicas, evitando a complexidade de gerenciar sessões reais durante os testes. A skill abstrai as APIs do Clerk, fornecendo métodos como `clerk.setSession()` ou `clerk.signIn()` diretamente nos testes, o que torna a escrita dos cenários de autenticação mais intuitiva e menos verbosa. Ao adotar esta skill, a equipe pode garantir que os fluxos críticos de autenticação do aplicativo estejam sempre funcionando conforme o esperado, aumentando a confiança nas entregas.

Funciona com~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/clerk/skills/tree/main/skills/clerk-testing

Installed? Explore more Programação e Desenvolvimento skills: steipete/bluebubbles, steipete/eightctl, steipete/blucli · View all 6 →

Perguntar na sua IA favorita

Abre um novo chat com esta habilidade de agente já pré-carregada.

Documentação

O que clerk-testing faz?

Testes E2E para aplicativos Clerk. Use com Playwright ou Cypress para testes de fluxo de autenticação.

Visão Geral

Esta skill configura o ambiente e fornece utilitários para testar fluxos de autenticação do Clerk de forma integrada com frameworks de testes E2E como Playwright e Cypress.

Funcionalidades Principais

  • Simulação de estados de autenticação (logado, não logado, etc.)
  • Helpers para login e registro em testes
  • Suporte a sessões de diferentes tipos de usuário
  • Compatível com Playwright e Cypress

Requisitos

  • Projeto Node.js com Clerk configurado
  • Playwright ou Cypress instalado

Instalação

npm install @clerk/testing --save-dev

Uso Básico com Playwright

Configure o arquivo de teste:

import { test, expect } from '@playwright/test';
import { clerkSetup } from '@clerk/testing/playwright';

test.beforeEach(async ({ page }) => {
    await clerkSetup({ page });
});

test('usuário pode fazer login', async ({ page }) => {
    await page.goto('/login');
    // Use helpers do Clerk aqui
    await page.clerk.signIn({ strategy: 'password', identifier: '[email protected]', password: 'password' });
    await expect(page.locator('h1')).toHaveText('Dashboard');
});

Uso Básico com Cypress

No arquivo de suporte do Cypress:

import '@clerk/testing/cypress';

describe('Fluxo de Login', () => {
    it('deve permitir login com sucesso', () => {
        cy.visit('/login');
        cy.clerkSignIn({ strategy: 'password', identifier: '[email protected]', password: 'password' });
        cy.url().should('include', '/dashboard');
    });
});

Configuração Avançada

Para cenários que exigem um usuário específico, use as funções auxiliares:

import { clerkSetup, createTestUser } from '@clerk/testing/playwright';

test('acesso como administrador', async ({ page }) => {
    const user = await createTestUser({ email: '[email protected]', password: 'admin123' });
    await clerkSetup({ page, signInAs: user });
    await page.goto('/admin');
    // Testes específicos de admin
});

Solução de Problemas

  • Erro de autenticação: Verifique se as credenciais de teste estão corretas e se o ambiente de teste está devidamente configurado.
  • Timeout: Aumente o tempo limite padrão do test runner se os fluxos de autenticação forem lentos.
  • Sessão não persistente: Certifique-se de que os cookies e armazenamento local estão sendo gerenciados corretamente nos hooks de teste.

Recursos Adicionais

Individual skills in this repo

This repo contains 19 individual skills — each has its own dedicated page.

clerk/clerk

Clerk authentication router. Use when user asks about adding authentication, setting up Clerk, custom sign-in flows, Swift or native iOS auth, native Android auth, Next.js patterns, React patterns, Vue patterns, Nuxt patterns, Astro patterns, TanStack Start patterns, Expo patterns, React Router patterns, Chrome Extension patterns, organizations, billing, subscriptions, payments, pricing, plans, seat-based pricing, feature entitlements, syncing users, or testing. Automatically routes to the specific skill based on their task.

clerk/clerk-android

Implement Clerk authentication for native Android apps using Kotlin and Jetpack Compose with clerk-android source-guided patterns. Use for prebuilt AuthView/UserButton or custom API-driven auth flows. Do not use for Expo or React Native projects.

clerk/clerk-astro-patterns

Astro patterns with Clerk — middleware, SSR pages, island components, API routes, static vs SSR rendering. Triggers on: astro clerk, clerk astro middleware, astro protected page, clerk island component, astro API route auth, clerk astro SSR.

clerk/clerk-backend-api

Clerk Backend REST API explorer and executor. Browse tags, inspect endpoint schemas, and execute authenticated requests. Use when listing users, managing organizations, or calling any Clerk API endpoint.

clerk/clerk-billing

Clerk Billing for subscription management - render Clerk's PricingTable and in-app checkout drawer, configure subscription plans, seat-limit plans for B2B, feature entitlements with has(), and billing webhooks. Use for SaaS monetization, plan gating, checkout flows, trials, invoicing, and subscription lifecycle management.

clerk/clerk-chrome-extension-patterns

Chrome Extension auth with @clerk/chrome-extension -- popup/sidepanel setup, syncHost for OAuth/SAML via web app, createClerkClient for service workers and headless extensions, stable CRX ID. Triggers on: Chrome extension auth, Plasmo clerk, popup sign-in, syncHost, background service worker token, createClerkClient, headless extension.

clerk/clerk-custom-ui

Custom authentication flows and component appearance - hooks (useSignIn, useSignUp), themes, colors, fonts, CSS. Use for custom sign-in/sign-up flows, appearance styling, visual customization, branding.

clerk/clerk-expo

Implement Clerk authentication for Expo and React Native apps using @clerk/expo source-guided patterns. Use for prebuilt AuthView/UserButton or custom hook-driven auth flows. Do not use for native iOS/Swift, native Android/Kotlin, or web framework projects.

clerk/clerk-expo-patterns

Expo / React Native patterns with Clerk — SecureStore token cache, OAuth deep linking, useAuth in native, Expo Router protected routes, push notifications with user context. Triggers on: expo clerk, clerk react native, SecureStore token cache, expo router auth, OAuth deep link clerk, mobile auth clerk.

clerk/clerk-nextjs-patterns

Advanced Next.js patterns - middleware, Server Actions, caching with Clerk.

clerk/clerk-nuxt-patterns

Nuxt 3 auth patterns with @clerk/nuxt - middleware, composables, server API routes, SSR. Triggers on: Nuxt auth, useAuth composable, clerkMiddleware Nuxt, server API Clerk, Nuxt route protection.

clerk/clerk-orgs

Clerk Organizations for B2B SaaS - create multi-tenant apps with org switching, role-based access, verified domains, and enterprise SSO. Use for team workspaces, RBAC, org-based routing, member management.

clerk/clerk-react-patterns

React SPA auth patterns with @clerk/react for Vite/CRA - ClerkProvider setup, useAuth/useUser/useClerk hooks, React Router protected routes, custom sign-in flows. Triggers on: Vite Clerk setup, React Router auth, useAuth hook, protected route, custom sign-in form React.

clerk/clerk-react-router-patterns

React Router v7 patterns with Clerk — rootAuthLoader, getAuth in loaders, clerkMiddleware, protected routes, SSR user data, org switching. Triggers on: react-router auth, rootAuthLoader, getAuth loader, react-router protected route, loader authentication, SSR auth react-router.

clerk/clerk-setup

Add Clerk authentication to any project by following the official quickstart guides.

clerk/clerk-swift

Implement Clerk authentication for native Swift and iOS apps using ClerkKit and ClerkKitUI source-guided patterns. Use for prebuilt AuthView or custom native flows. Do not use for Expo or React Native projects.

clerk/clerk-tanstack-patterns

TanStack React Start auth patterns with @clerk/tanstack-react-start - createServerFn, beforeLoad guards, loaders, Vinxi server. Triggers on: TanStack auth, createServerFn clerk, beforeLoad protection, TanStack Start middleware.

clerk/clerk-vue-patterns

Vue 3 patterns with Clerk — composables (useAuth, useUser, useClerk, useOrganization), Vue Router guards, Pinia auth store integration. Triggers on: vue clerk, useAuth vue, clerk composables, vue router clerk guard, pinia auth clerk. For Nuxt, use clerk-nuxt-patterns instead.

clerk/clerk-webhooks

Clerk webhooks for real-time events and data syncing. Verify with verifyWebhook from the framework-specific package. Handle user, session, organization, billing, and payment events. Build event-driven features like database sync, notifications, and integrations.

Habilidades Relacionadas