Claude Code Test Runner

AI Automation
Open Source

Overview

Claude Code Test Runner represents a paradigm shift in end-to-end test automation. This open-source framework enables teams to define comprehensive browser tests using simple natural language descriptions, while Claude Code handles the complex decisions around element selection, timing, and validation. The result is a testing approach that combines the scalability of automated testing with the adaptability and intuition of manual testing.

The Testing Automation Challenge

Traditional E2E testing frameworks require significant technical investment and ongoing maintenance overhead. Development teams face recurring challenges that impact testing effectiveness:

Brittle Test Maintenance

  • Fixed selectors break when UI elements move or change appearance
  • Minor design updates require extensive test suite modifications
  • Network delays and loading states cause intermittent test failures
  • Edge cases and error conditions require explicit handling in test code

Technical Barrier to Test Creation

  • Writing effective E2E tests requires deep technical knowledge of testing frameworks
  • Non-technical team members cannot contribute to test coverage
  • Test scenarios often lag behind feature development due to implementation complexity
  • Comprehensive test coverage becomes prohibitively expensive to maintain

Human-Intuitive Test Automation

Claude Code Test Runner addresses these fundamental limitations by leveraging AI to bridge the gap between human test descriptions and browser automation execution.

Natural Language Test Definitions

Tests are defined as JSON arrays containing sequential steps written in plain English. This approach allows product managers, QA professionals, and developers to collaborate on test scenarios using shared vocabulary rather than technical implementation details.

Adaptive Element Discovery

Instead of relying on brittle CSS selectors or XPath expressions, Claude Code uses visual understanding and contextual reasoning to locate interface elements. When buttons move, forms change layout, or new UI elements appear, the system adapts without requiring test modifications.

Intelligent Error Recovery

The framework handles transient issues that commonly cause traditional tests to fail. Network delays, loading states, and minor interface inconsistencies are resolved through AI-driven decision making rather than explicit error handling code.

Technical Architecture

Core Components

The system architecture consists of three integrated layers that enable sophisticated AI-powered test execution:

Test Runner CLI: Built with Bun for optimal performance, the orchestrator manages test execution lifecycles, coordinates between system components, and generates comprehensive test reports in both CTRF and Markdown formats.

Model Context Protocol Integration: Two specialized MCP servers provide Claude Code with essential capabilities:

  • Playwright MCP: Delivers standardized browser automation tools through the MCP interface
  • Test State MCP: Maintains real-time test execution state and enables Claude Code to query current test plans and update step completion status

Claude Code SDK Integration: The framework integrates directly with Claude Code's reasoning capabilities, enabling sophisticated decision-making around test step execution, element identification, and validation logic.

Execution Flow

The Test State MCP server creates a critical feedback loop between the test runner and Claude Code. Through exposed tools like get_test_plan and update_test_step, Claude Code maintains awareness of the current test context and reports execution results back to the orchestrator. This architecture ensures proper test coordination while enabling AI-driven flexibility in test execution.

Deployment and Integration

The complete testing solution is packaged as a Docker container and distributed through GitHub Container Registry. Teams can integrate Claude Code Test Runner directly into CI/CD pipelines through GitHub Actions, enabling automated test execution on code changes, scheduled intervals, or manual triggers.

Debugging and Observability

The framework generates comprehensive debugging artifacts for each test execution:

Test Artifacts

  • Playwright Traces: Complete browser interaction recordings for detailed failure analysis
  • AI Decision Screenshots: Visual captures at critical test decision points showing what Claude Code observed
  • Execution Logs: Detailed step-by-step execution records with AI reasoning explanations

Report Generation

Test results are automatically generated in industry-standard CTRF format for integration with existing test reporting tools, alongside human-readable Markdown summaries for stakeholder communication.

Production Readiness Features

Scalable Test Execution

The containerized architecture supports horizontal scaling across multiple test environments. Teams can execute extensive test suites in parallel by deploying multiple container instances, with execution costs scaling linearly with Claude Code API usage.

Configuration Flexibility

The CLI tool provides extensive configuration options including custom result directories, verbose logging modes, and configurable interaction limits to prevent runaway test executions.

Authentication Options

Supports both OAuth tokens and direct API keys for Claude Code authentication, enabling flexible deployment across different organizational security requirements.

Open Source Contribution

This project exemplifies the practical application of AI in software development workflows. By open-sourcing the complete framework, we enable the broader development community to experiment with AI-powered testing approaches and contribute improvements to the testing methodology.

The project demonstrates how Model Context Protocol can enable sophisticated AI integrations while maintaining clean separation of concerns between AI reasoning and system capabilities.