Skip to content

JPeetz/agent-skills / skills/qa-testing/playwright-e2e-testing

playwright-e2e-testing

Verified

Use this skill when writing, debugging, or maintaining Playwright end-to-end tests in TypeScript, JavaScript, or Python. Covers test structure and architecture (Page Object Model, fixtures, custom matchers), locator strategy (role-based, test-ID, accessible selectors), auto-waiting and retry, API/network mocking, visual regression, component testing (React, Vue, Svelte), accessibility audits (axe-core), device emulation, authentication and session management (multi-profile, OAuth, 2FA), performance testing (Web Vitals, Lighthouse), CI/CD configuration (GitHub Actions, GitLab CI, sharding), flaky test detection and auto-healing, test data/fixtures, i18n testing, Electron and browser extension testing, security testing (XSS, CSRF, CSP), and WebSocket testing. Designed for agentic platforms — Claude Code, Codex, Cursor, Gemini CLI, OpenClaw, GitHub Copilot, Windsurf, OpenCode, and all SKILL.md-compatible agents.

FileKindSize
CHANGELOG.mdmarkdown2.2 KB
LICENSEother1.0 KB
SKILL.mdskill md23.4 KB
evals/evals.jsonconfig5.3 KB
references/ci-cd-patterns.mdmarkdown2.5 KB
references/locator-strategies.mdmarkdown3.0 KB
references/testing-types-matrix.mdmarkdown3.2 KB
scripts/flake-detector.shexecutablescript2.0 KB
scripts/generate-auth-profile.tsscript3.4 KB
scripts/validate-playwright-setup.shexecutablescript2.2 KB

scripts/generate-auth-profile.ts

View on GitHub
#!/usr/bin/env node
/**
 * generate-auth-profile.ts — Generates and saves Playwright authentication profiles
 * Usage: npx tsx generate-auth-profile.ts [--role=admin|customer] [--output=path]
 *
 * Environment variables:
 *   BASE_URL — Application base URL
 *   TEST_USER_EMAIL — Login email
 *   TEST_USER_PASSWORD — Login password
 *   AUTH_OUTPUT_DIR — Output directory for storage state files
 */
import { chromium } from '@playwright/test';

interface AuthConfig {
  role: string;
  email: string;
  password: string;
  loginUrl: string;
  successUrl: string;
  outputPath: string;
}

async function generateAuthProfile(config: AuthConfig): Promise<void> {
  console.log(`🔐 Generating auth profile for role: ${config.role}`);

  const browser = await chromium.launch({ headless: true });
  const context = await browser.newContext();
  const page = await context.newPage();

  try {
    await page.goto(config.loginUrl);
    console.log(`   Loaded login page: ${config.loginUrl}`);

    await page.getByLabel(/email/i).fill(config.email);
    await page.getByLabel(/password/i).fill(config.password);
    await page.getByRole('button', { name: /sign in|log in|login/i }).click();

    await page.waitForURL(new RegExp(config.successUrl));
    console.log(`   Authentication successful`);

    await context.storageState({ path: config.outputPath });
    console.log(`   Profile saved: ${config.outputPath}`);
  } catch (error) {
    console.error(`❌ Auth failed for ${config.role}:`, error);
    // Take a screenshot for debugging
    await page.screenshot({ path: `auth-debug-${config.role}.png` });
    throw error;
  } finally {
    await browser.close();
  }
}

async function main() {
  const args = process.argv.slice(2);
  const role = args.find(a => a.startsWith('--role='))?.split('=')[1] || 'admin';
  const outputDir = process.env.AUTH_OUTPUT_DIR || 'playwright/.auth';

  const baseUrl = process.env.BASE_URL || 'http://localhost:3000';
  const email = process.env.TEST_USER_EMAIL;
  const password = process.env.TEST_USER_PASSWORD;

  if (!email || !password) {
    console.error('❌ TEST_USER_EMAIL and TEST_USER_PASSWORD must be set');
    process.exit(1);
  }

  // Ensure output directory exists
  const fs = await import('fs');
  if (!fs.existsSync(outputDir)) {
    fs.mkdirSync(outputDir, { recursive: true });
  }

  const configs: AuthConfig[] = [];

  switch (role) {
    case 'all':
    case 'admin':
      configs.push({
        role: 'admin',
        email,
        password,
        loginUrl: `${baseUrl}/login`,
        successUrl: 'dashboard',
        outputPath: `${outputDir}/admin.json`,
      });
      break;
    case 'all':
    case 'customer':
      configs.push({
        role: 'customer',
        email: process.env.TEST_CUSTOMER_EMAIL || email,
        password: process.env.TEST_CUSTOMER_PASSWORD || password,
        loginUrl: `${baseUrl}/login`,
        successUrl: 'dashboard',
        outputPath: `${outputDir}/customer.json`,
      });
      break;
    default:
      configs.push({
        role,
        email,
        password,
        loginUrl: `${baseUrl}/login`,
        successUrl: 'dashboard',
        outputPath: `${outputDir}/${role}.json`,
      });
  }

  for (const config of configs) {
    await generateAuthProfile(config);
  }

  console.log(`\n✅ All auth profiles generated in ${outputDir}/`);
}

main().catch((error) => {
  console.error('Fatal error:', error);
  process.exit(1);
});
rea-analysis-optimizationmorluto/reaOptimize REA providers and shared analysis workflows for agent context, latency, CPU, and memory while preserving correctness and Evidence. Use for analysis bottlenecks and cache or query design; CI/test-suite optimization belongs to rea-ci-tests-audit.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-ci-tests-auditmorluto/reaAudit REA CI and test suites for correctness, fixture drift, false passes, and measured performance; use for suite or workflow investigations and efficiency changes, rather than ordinary feature testing or a single test failure.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
rea-tool-designmorluto/reaAudit, investigate, design, or change REA investigation tools, CLI/MCP contracts, provider capabilities, and Evidence semantics.Stars: 469kUpdated Claude CodeCodexVerifiedInstall
ponytail-auditDietrichGebert/ponytailQuality audit of the whole repo: bugs, security, real load, missing tests, speed, and what to delete. Most important first.Stars: 194kUpdated Claude CodeCodexVerifiedInstall