Skip to main content

Testing Components

The Testing category includes specialists for test generation, test automation, quality assurance, and comprehensive testing strategies across unit, integration, E2E, and performance testing.

Browse Testing Components

Explore all testing components at aitmpl.com

Quick Install

# Install testing essentials
npx claude-code-templates@latest \
  --agent test-generator \
  --command setup-testing \
  --command e2e-setup \
  --hook testing/test-runner

# Or install the testing template
npx claude-code-templates@latest --template testing-suite

Testing Agents

Test Generator

Automated test generation with comprehensive coverageExpertise:
  • Unit test generation
  • Integration test design
  • E2E test scenarios
  • Test data factories
  • Mocking and stubbing strategies
  • Coverage analysis
  • Edge case identification
Technologies:
  • Jest, Vitest, Mocha
  • React Testing Library, Vue Test Utils
  • Playwright, Cypress, Puppeteer
  • Supertest for API testing
  • MSW (Mock Service Worker)
npx claude-code-templates@latest --agent test-generator
Example Usage:
@test-generator Generate comprehensive tests for the user
authentication service with 80%+ coverage. Include:
- Unit tests for password hashing
- Integration tests for login/logout
- E2E tests for complete auth flow
- Edge cases (expired tokens, invalid credentials)

Test Runner

Test execution automation and orchestrationExpertise:
  • Test suite execution
  • Parallel test running
  • Test result reporting
  • Flaky test detection
  • Test prioritization
npx claude-code-templates@latest --agent test-runner

Testing Commands

Test Infrastructure Setup

Setup Testing

Configure comprehensive testing infrastructureSets up:
  • Test framework (Jest/Vitest/Mocha)
  • Test runners and reporters
  • Coverage tools
  • Mocking libraries
  • CI/CD integration
  • Test utilities
npx claude-code-templates@latest --command setup-testing
Usage:
/setup-testing
Creates:
  • jest.config.js or vitest.config.js
  • Test setup files
  • Example test files
  • Coverage configuration
  • CI/CD test workflow

E2E Setup

Set up end-to-end testing with Playwright or CypressOptions:
  • Playwright (recommended)
  • Cypress
  • TestCafe
  • Puppeteer
npx claude-code-templates@latest --command e2e-setup
Features:
  • Browser automation setup
  • Page object models
  • Test fixtures
  • Screenshot/video recording
  • CI/CD integration

Setup Comprehensive Testing

Complete testing setup with all test types
npx claude-code-templates@latest --command setup-comprehensive-testing

Setup Load Testing

Configure load and performance testingTools:
  • k6
  • Artillery
  • Apache JMeter
npx claude-code-templates@latest --command setup-load-testing

Setup Visual Testing

Set up visual regression testing
npx claude-code-templates@latest --command setup-visual-testing

Testing Hooks

Test Runner Hook

Automatically run tests before commitsBehavior:
  • Runs before each commit (pre-commit hook)
  • Executes tests for changed files
  • Blocks commit if tests fail
  • Shows test results and failures
Configuration:
  • Run all tests or only affected tests
  • Set timeout limits
  • Configure coverage thresholds
npx claude-code-templates@latest --hook testing/test-runner
Example:
git commit -m "Add user service"

# Running tests for changed files...
# ✓ user.service.test.ts (5 tests)
# ✓ auth.service.test.ts (8 tests)
# 
# 13 tests passed
# Coverage: 87%
# Commit successful

Testing Strategies

Testing Pyramid

        /\
       /E2E\
      /______\
     /        \
    /Integration\
   /____________\
  /              \
 /   Unit Tests   \
/__________________\
Unit Tests (70%): Fast, isolated tests for individual functions/methods Integration Tests (20%): Test module interactions and API endpoints E2E Tests (10%): Test complete user workflows through the UI

Test-Driven Development (TDD)

# 1. Write failing test
@test-generator Generate test for user registration validation

# 2. Implement feature
@backend-developer Implement user registration

# 3. Run tests
/test-coverage

# 4. Refactor
@code-architect Refactor user registration for better design

Testing Workflows

Complete Testing Setup

# 1. Install testing tools
npx claude-code-templates@latest \
  --agent test-generator \
  --command setup-testing \
  --command e2e-setup \
  --hook testing/test-runner

# 2. Configure testing infrastructure
/setup-testing
/e2e-setup playwright

# 3. Generate tests
@test-generator Generate tests for existing codebase with 80% coverage

# 4. Run tests
npm test

# 5. Check coverage
/test-coverage

Feature Development with Tests

# 1. Write test first (TDD)
@test-generator Generate tests for new payment processing feature

# 2. Implement feature
@backend-developer Implement payment processing

# 3. Run tests
npm test

# 4. Verify coverage
/test-coverage src/services/payment.service.ts --threshold 85

# 5. Add E2E tests
@test-generator Generate E2E tests for payment flow

CI/CD Testing Pipeline

# Install tools
npx claude-code-templates@latest \
  --command setup-testing \
  --command test-coverage

# Create GitHub Actions workflow
@devops-engineer Set up testing workflow:
- Run unit tests on PR
- Run integration tests on merge to main
- Run E2E tests before deploy
- Fail if coverage < 80%
- Upload coverage reports

Best Practices

1. Comprehensive Coverage

# Aim for 80%+ coverage
/test-coverage --threshold 80

# Focus on critical paths
@test-generator Prioritize tests for:
- Authentication and authorization
- Payment processing
- Data validation
- Error handling

2. Test Independence

# Each test should be independent
@test-generator Generate tests that:
- Don't rely on execution order
- Use test fixtures for setup
- Clean up after themselves
- Mock external dependencies

3. Fast Feedback

# Keep tests fast
@test-generator:
- Unit tests: < 100ms each
- Integration tests: < 1s each
- E2E tests: < 30s each

# Run tests in parallel
/setup-testing --parallel

4. Meaningful Tests

# Test behavior, not implementation
@test-generator Write tests that:
- Test user-facing behavior
- Verify business logic
- Check error scenarios
- Don't test implementation details

Real-World Examples

Example 1: API Testing

# Install testing tools
npx claude-code-templates@latest \
  --agent test-generator \
  --command setup-testing

# Generate API tests
@test-generator Generate tests for REST API:
- GET /users (list users)
- POST /users (create user)
- PUT /users/:id (update user)
- DELETE /users/:id (delete user)

Include:
- Happy path tests
- Validation errors
- Authentication checks
- Authorization checks

Example 2: Frontend Component Testing

# Install tools
npx claude-code-templates@latest \
  --agent test-generator \
  --command setup-testing

# Generate component tests
@test-generator Generate React tests for LoginForm component:
- Renders correctly
- Validates email format
- Validates password length
- Shows loading state
- Handles login success
- Handles login errors
- Disables submit when invalid

Example 3: E2E Testing

# Install E2E tools
npx claude-code-templates@latest \
  --agent test-generator \
  --command e2e-setup

# Setup E2E
/e2e-setup playwright

# Generate E2E tests
@test-generator Generate E2E tests for checkout flow:
1. User adds product to cart
2. User proceeds to checkout
3. User enters shipping info
4. User enters payment info
5. User confirms order
6. User sees confirmation page

Include error scenarios:
- Invalid credit card
- Out of stock items
- Network errors

Example 4: Load Testing

# Install load testing
npx claude-code-templates@latest --command setup-load-testing

# Setup
/setup-load-testing k6

# Create load test
@test-generator Generate k6 load test:
- Target: 1000 RPS
- Duration: 5 minutes
- Ramp-up: 1 minute
- Endpoints: /api/products, /api/users
- Success criteria: p95 < 200ms, errors < 1%

Testing Template

npx claude-code-templates@latest --template testing-suite
Includes:
  • Test generator agent
  • Test runner agent
  • Setup testing command
  • E2E setup command
  • Test coverage command
  • Test runner hook (pre-commit)
  • Load testing setup
  • Visual testing setup

Test Types

Unit Tests

  • Test individual functions/methods
  • Fast execution (< 100ms)
  • No external dependencies
  • High code coverage

Integration Tests

  • Test module interactions
  • Test API endpoints
  • Test database operations
  • Mock external services

E2E Tests

  • Test complete user workflows
  • Browser automation
  • Real user interactions
  • Covers multiple systems

Performance Tests

  • Load testing (k6, Artillery)
  • Stress testing
  • Spike testing
  • Soak testing

Visual Tests

  • Screenshot comparison
  • Visual regression detection
  • Cross-browser testing
  • Responsive design testing

Next Steps