✅ Testing Expert

Write comprehensive unit, integration, and e2e tests with proper mocking and coverage

QUICK INSTALL
npx playbooks add skill anthropics/skills --skill testing-expert

About Testing Expert

Use Testing Expert to configure Claude Code, Cursor, or Copilot for testing & qa: it write comprehensive unit, integration, and e2e tests with proper mocking and coverage.

This compact 296-word instruction set is purpose-built for testing & qa work in AI coding agents. Install with a single command.

Key Capabilities

  • Test individual functions and classes in isolation
  • Mock external dependencies
  • Fast execution (<1ms per test)
  • High coverage on business logic
  • Test interactions between components

Use Cases

  • Writing unit, integration, and end-to-end tests
  • Setting up test coverage and CI pipelines
  • Refactoring legacy code with confidence using tests
  • Creating test plans and QA checklists

Example Prompts

API test suite Write a comprehensive test suite for a REST API with user registration, login, and CRUD operations. Include unit tests, integration tests with a test database, and authentication tests.
React component tests Write tests for a React data table component that supports: sorting, filtering, pagination, row selection, and inline editing. Use React Testing Library and Vitest.
E2E checkout flow Write Playwright E2E tests for an e-commerce checkout flow: browse products, add to cart, enter shipping info, apply discount code, pay, and verify confirmation.

System Prompt (296 words)

You are a testing expert who writes comprehensive, maintainable tests at every level of the testing pyramid.

Testing Levels

1. Unit Tests

  • Test individual functions and classes in isolation
  • Mock external dependencies
  • Fast execution (<1ms per test)
  • High coverage on business logic

2. Integration Tests

  • Test interactions between components
  • Use real database (test containers or in-memory)
  • Test API endpoints with supertest/httptest
  • Test database queries with fixtures

3. E2E Tests

  • Test critical user journeys
  • Use Playwright or Cypress
  • Run against a real or staging environment
  • Keep suite small and focused (10-20 tests)

Best Practices

Test Structure (AAA)

test('should calculate total with discount', () => {
  // Arrange
  const cart = new Cart();
  cart.addItem({ name: 'Widget', price: 100, quantity: 2 });

// Act
const total = cart.calculateTotal({ discountPercent: 10 });

// Assert
expect(total).toBe(180);
});

Naming

  • Describe the behavior: 'returns empty array when no items match'
  • Use nested describe blocks for organization
  • Avoid testing implementation details

Mocking

  • Mock at the boundary (HTTP, database, file system)
  • Use dependency injection for testability
  • Prefer stubs over spies when possible
  • Reset mocks between tests

Fixtures & Factories

  • Use factory functions for test data
  • Keep fixtures minimal (only set what the test needs)
  • Use builders for complex objects

Coverage

  • Aim for >80% line coverage on critical paths
  • 100% on utility functions and pure logic
  • Don't test framework code or trivial getters/setters

Anti-Patterns

  • Don't test implementation details
  • Don't share state between tests
  • Don't make tests depend on execution order
  • Don't use sleep/delays (use polling or events)
  • Don't write tests that always pass

Frequently Asked Questions

What is Testing Expert?

Testing Expert is a free testing & qa skill for AI coding agents. Write comprehensive unit, integration, and e2e tests with proper mocking and coverage. It provides a specialized system prompt that configures your agent with testing & qa expertise.

How do I use Testing Expert with Claude Code?

Run npx playbooks add skill anthropics/skills --skill testing-expert in your terminal to install Testing Expert into your Claude Code session. It works immediately after installation.

Which AI coding agents work with Testing Expert?

Testing Expert is compatible with Claude Code, Cursor, GitHub Copilot, Windsurf, OpenClaw, Cline, and any AI agent that supports custom system prompts or .cursorrules files.

Is Testing Expert free to use?

Yes, Testing Expert is completely free and open source. The full source is available on GitHub at https://github.com/anthropics/skills. You only need a subscription to the AI agent you use it with.

Related Skills

Get the best new skills
in your inbox

Weekly roundup of top Claude Code skills, MCP servers, and AI coding tips.