amo-tech-ai avatar

testing-e2e-with-playwright

Run end-to-end browser tests using Playwright MCP. Use when testing web applications, validating use

by amo-tech-ai|Open Source

Playwright E2E Testing Skill

Production-ready E2E testing using Playwright MCP for the Medellin Spark platform

<p align="center"> <strong>Simple • Fast • Reliable</strong><br> Test your entire user journey in minutes, not hours. </p>

šŸš€ Quick Start

Run your first test in 60 seconds:

# 1. Install Playwright MCP
npm install -g @playwright/mcp@latest

# 2. Start your dev server
pnpm dev

# 3. Run smoke test
npm run test:smoke

That's it! Your first E2E test is complete. šŸŽ‰


šŸ“‹ What You Get

This skill provides:

āœ… 3 Ready-to-Run Test Playbooks

  • Smoke test (2 min) - Quick health check
  • Auth flow (5 min) - Login/logout testing
  • Full journey (10-15 min) - Complete pitch deck creation

āœ… Autonomous Agent

  • Smart test orchestration
  • Intelligent error handling
  • Automatic screenshot capture
  • Network & console monitoring

āœ… Production-Ready CI/CD

  • GitHub Actions workflows
  • Automated PR checks
  • Daily health monitoring
  • Test result artifacts

āœ… Complete Documentation

  • SKILL.md - Core instructions
  • RUNBOOK.md - Operations guide
  • Examples - TypeScript reference implementations
  • Playbooks - Step-by-step test scripts

šŸŽÆ Use Cases

Before Every Deployment:

npm run test:all  # Verify everything works

After Code Changes:

npm run test:smoke  # Quick sanity check

Testing New Features:

npm run test:pitch-deck  # Full user journey

Debugging Issues:

# Run with browser visible (no --headless)
npx @playwright/mcp < playbooks/pitch-deck-wizard.md

šŸ“ Project Structure

.claude/skills/playwright-e2e-skill/
ā”œā”€ā”€ SKILL.md                    # Main skill instructions
ā”œā”€ā”€ README.md                   # This file
ā”œā”€ā”€ RUNBOOK.md                  # Operations & troubleshooting
ā”œā”€ā”€ package.json                # Dependencies & scripts
│
ā”œā”€ā”€ playbooks/                  # Test scenarios
│   ā”œā”€ā”€ smoke.md               # 2-min health check
│   ā”œā”€ā”€ auth.md                # 5-min auth flow
│   └── pitch-deck-wizard.md   # 10-15 min full journey
│
ā”œā”€ā”€ examples/                   # TypeScript examples
│   ā”œā”€ā”€ basic-navigation.ts    # Simple test pattern
│   ā”œā”€ā”€ form-submission.ts     # Form testing
│   └── full-journey.ts        # Complete user flow
│
ā”œā”€ā”€ .github/workflows/          # CI/CD automation
│   └── e2e-tests.yml          # GitHub Actions config
│
└── .claude/agents/             # Autonomous testing agent
    └── eventos-playwright-agent/
        ā”œā”€ā”€ agent.json         # Agent manifest
        ā”œā”€ā”€ handler.ts         # Test orchestration logic
        └── types.ts           # TypeScript definitions

šŸ› ļø Installation

Prerequisites

  • Node.js 20+
  • pnpm or npm
  • Chrome/Chromium browser

Setup

# 1. Install Playwright MCP globally
npm install -g @playwright/mcp@latest

# 2. Install Playwright browsers
npx playwright install chromium

# 3. Install project dependencies
cd .claude/skills/playwright-e2e-skill
npm install

# 4. Verify installation
npm run test:smoke

šŸ“š Available Tests

1. Smoke Test (2 min)

What it tests:

  • Homepage loads
  • Navigation works
  • No console errors
  • API calls succeed

When to run: Before every deployment, after every code change

Command:

npm run test:smoke

Playbook: playbooks/smoke.md


2. Auth Flow (5 min)

What it tests:

  • Login form works
  • Authentication succeeds
  • Protected routes accessible
  • Session persists
  • Logout works

When to run: After auth code changes, before production deploy

Command:

npm run test:auth

Playbook: playbooks/auth.md


3. Pitch Deck Wizard - Full Journey (10-15 min)

What it tests:

  • Chat interface works
  • AI responds correctly
  • Progress tracking updates
  • Deck generation completes
  • All 10 slides render
  • Export functionality works

When to run: Before releases, weekly regression testing

Command:

npm run test:pitch-deck

Playbook: playbooks/pitch-deck-wizard.md


šŸŽ¬ Example Output

šŸš€ Starting full pitch deck wizard journey...

šŸ“ PHASE 1: Setup & Navigation
  āœ… Wizard loaded

šŸ“ PHASE 2: AI Conversation & Data Collection
  šŸ’¬ Sending message 1/6...
  šŸ’¬ Sending message 2/6...
  šŸ’¬ Sending message 3/6...
  šŸ’¬ Sending message 4/6...
  šŸ’¬ Sending message 5/6...
  šŸ’¬ Sending message 6/6...
  āœ… Conversation: 6 exchanges

šŸ“ PHASE 3: Deck Generation
  ā³ Waiting for Generate Deck button...
  šŸ”„ Generating deck...
  ā³ Waiting for generation to complete...
  āœ… Deck generated

šŸ“ PHASE 4: Slide Validation
  šŸ“Š Detected 10 slide references
  āœ… Found slide: Problem
  āœ… Found slide: Solution
  āœ… Found slide: Product
  āœ… Found slide: Market
  āœ… Found slide: Business Model
  āœ… Found slide: Team
  āœ… Found slide: Traction
  āœ… Found slide: Ask
  šŸ“ˆ Found 8/8 expected slide types
  šŸ” Testing slide interaction...
  āœ… Slide interaction works

šŸ“ PHASE 5: Final Verification
  āœ… No console errors
  šŸ“” Network: 45 total, 12 API calls
  āœ… All API calls successful

============================================================
āœ… FULL JOURNEY COMPLETE
============================================================
Phases: āœ… Wizard loaded → āœ… Conversation: 6 exchanges → āœ… Deck generated → āœ… 10 slides generated → āœ… Slide interaction works
Conversation exchanges: 6
Slides generated: 10
Screenshots: 7
Errors: 0

šŸ”§ Configuration

NPM Scripts

All scripts are defined in package.json:

{
  "scripts": {
    "test:smoke": "Quick 2-min health check",
    "test:auth": "5-min authentication flow",
    "test:pitch-deck": "10-15 min full journey with video",
    "test:all": "Run all tests sequentially",
    "test:ci": "Headless mode for CI/CD",
    "examples:basic": "Run basic navigation example",
    "examples:form": "Run form submission example",
    "examples:full": "Run full journey example",
    "clean": "Remove test artifacts",
    "setup": "Install Playwright MCP"
  }
}

Environment Variables

Create .env file (optional):

# Base URL for tests
PLAYWRIGHT_BASE_URL=http://localhost:8080

# Default timeout (ms)
PLAYWRIGHT_TIMEOUT=30000

# Headless mode
PLAYWRIGHT_HEADLESS=true

šŸ¤– Using the Agent

The eventos-playwright-agent provides autonomous test execution:

Trigger phrases:

  • "test the full user journey"
  • "run e2e tests"
  • "validate pitch deck wizard"
  • "run smoke tests"

Example usage:

import { EventosPlaywrightAgent } from '.claude/agents/eventos-playwright-agent';

const agent = new EventosPlaywrightAgent({
  baseUrl: 'http://localhost:8080',
  timeout: 30000,
  screenshotDir: './test-results'
});

// Run smoke test
const result = await agent.runSmokeTest(context);

// Run full journey
const journeyResult = await agent.runPitchDeckJourney(context);

// Generate report
const report = agent.generateReport([result, journeyResult]);
console.log(report);

šŸ—ļø CI/CD Integration

GitHub Actions

Tests run automatically on:

  • Push to main/develop → Smoke tests
  • Pull requests → Smoke + Auth tests
  • Daily at 6 AM UTC → Smoke tests
  • Manual trigger → Choose which suite to run

See .github/workflows/e2e-tests.yml for configuration.

Manual CI Run

# Run CI-mode tests locally
npm run test:ci

šŸ“– Learning Resources

Start here:

  1. SKILL.md - Core skill instructions and tool reference
  2. playbooks/smoke.md - Simplest test example
  3. examples/basic-navigation.ts - Code example

Go deeper: 4. playbooks/pitch-deck-wizard.md - Complex journey 5. RUNBOOK.md - Operations & troubleshooting 6. handler.ts - Agent implementation


šŸ› Troubleshooting

Tests failing? Check RUNBOOK.md for solutions to common issues:

  • Browser already in use
  • Dev server not running
  • Flaky tests
  • AI not responding
  • RLS blocking data
  • Slow execution

Quick fixes:

# Reset everything
pkill -f chromium
rm -rf test-results
npm run test:smoke

# View detailed logs
cat test-results/*.log

# Debug visually (no headless)
npx @playwright/mcp < playbooks/smoke.md

šŸ“Š Performance Benchmarks

TestExpectedGoodAcceptable
Smoke Test<2 min<1 min<3 min
Auth Test<5 min<3 min<7 min
Full Journey<15 min<10 min<20 min

šŸ¤ Contributing

Adding a new test:

  1. Create playbook in playbooks/my-test.md
  2. Add npm script to package.json
  3. Test locally: npm run test:my-test
  4. Update this README
  5. Submit PR

Example playbook template:

# My Test Playbook

**Purpose**: Brief description
**Duration**: X minutes
**When to Run**: When to use this test

## Test Steps

### Step 1: Description
\`\`\`typescript
await browser_navigate({ url: "..." });
\`\`\`

### Step 2: Description
\`\`\`typescript
await browser_click({ element: "...", ref: "..." });
\`\`\`

šŸ“œ License

MIT - See project root for license details


šŸ™‹ Support

Need help?

  1. Check SKILL.md for tool reference
  2. Check RUNBOOK.md for troubleshooting
  3. Review examples/ for code patterns
  4. Check playbooks/ for test scenarios

Found a bug?

  1. Capture screenshots from test-results/
  2. Save console logs
  3. Document reproduction steps
  4. File GitHub issue with evidence

<p align="center"> <strong>Built with ā¤ļø for the Medellin Spark team</strong><br> <em>Simple, fast, and reliable E2E testing</em> </p>