🎯 English | 中文
YAML-based Playwright MCP testing framework CLI for Claude Code. This is the official CLI package that allows you to easily initialize, manage, and update a sophisticated testing framework in any project.
🚀 What's New: Revolutionary session persistence, multi-environment support, and smart HTML reporting with 84.95% test coverage.
npm install -g claude-test
npm install -g claude-test
cd your-project
claude-test init
Create a test file test-cases/login.yml
:
tags: [smoke, login]
steps:
- "Navigate to {{BASE_URL}}"
- "Fill username field with {{TEST_USERNAME}}"
- "Fill password field with {{TEST_PASSWORD}}"
- "Click login button"
- "Verify dashboard is displayed"
Create .env.dev
:
BASE_URL=https://example.com
TEST_USERNAME=testuser
TEST_PASSWORD=testpass123
GENERATE_REPORT=true
REPORT_STYLE=detailed
/run-yaml-test file:login.yml env:dev
/view-reports-index
Initialize the testing framework in your current project directory.
claude-test init [options]
Options:
-f, --force
- Force initialization even if framework already exists--verbose
- Show detailed output during initialization
Example:
# Basic initialization
claude-test init
# Force reinitialize with detailed output
claude-test init --force --verbose
Update the framework to the latest version.
claude-test update [options]
Options:
--backup
- Create backup before update--dry-run
- Show what would be updated without making changes--verbose
- Show detailed output
Example:
# Update with backup
claude-test update --backup
# Preview changes without applying
claude-test update --dry-run
# Detailed update process
claude-test update --verbose
Check framework version and status.
claude-test check [options]
Options:
--remote
- Check for remote updates (future feature)--fix
- Attempt to fix integrity issues automatically--verbose
- Show detailed output
Example:
# Basic status check
claude-test check
# Check and fix issues
claude-test check --fix
# Detailed status report
claude-test check --verbose
After initialization, your project will have a complete testing framework with:
- 🌍 Multi-Environment Support: Support for dev/test/prod environments
- 📚 Reusable Step Libraries: Modular and reusable test components
- 🗣️ Natural Language: Write tests in natural language descriptions
- 🔧 Environment Variables: Automatic configuration loading from .env files
- 📊 Smart Reporting: Beautiful HTML test reports with embedded data
- ⚡ Session Persistence: Faster test execution with persistent browser sessions
- 🚀 CLI Management: Easy installation, updates, and integrity checking
After running claude-test init
, your project will contain:
.claude/
├── commands/ # Claude Code commands
│ ├── run-yaml-test.md # Execute individual tests
│ ├── run-test-suite.md # Execute test suites
│ ├── validate-yaml-test.md # Validate test syntax
│ ├── validate-test-suite.md # Validate suite syntax
│ └── view-reports-index.md # View test reports
└── scripts/ # Framework automation scripts
├── yaml-test-processor.js # YAML test processing engine
├── create-report-data.js # Report data creation (Step 1)
├── gen-report.js # HTML report generation (Step 2)
├── scan-reports.js # Report indexing and organization
├── start-report-server.js # Local HTTP server for reports
└── suite-report-generator.js # Test suite report generator
The CLI automatically manages framework versions:
- Installation tracking: Records when and how the framework was installed
- Version compatibility: Ensures CLI and framework versions are compatible
- Automatic updates: Updates framework files while preserving customizations
- Integrity checking: Verifies all required files are present and valid
- Backup support: Optional backup creation before updates
- Node.js: >= 16.0.0
- Claude Code: With Playwright MCP integration
- NPM: For global installation
Test Suite (test-suites/e-commerce.yml
):
name: E-commerce Smoke Tests
description: Critical functionality tests for e-commerce site
tags: [smoke, e-commerce]
test-cases:
- test-cases/login.yml
- test-cases/product-search.yml
- test-cases/add-to-cart.yml
- test-cases/checkout.yml
Individual Test (test-cases/product-search.yml
):
tags: [smoke, search]
steps:
- include: login
- "Click search field"
- "Type 'laptop' in search field"
- "Press Enter"
- "Verify search results contain 'laptop'"
- "Verify at least 5 products are displayed"
Step Library (steps/login.yml
):
description: Standard login flow
steps:
- "Navigate to {{BASE_URL}}/login"
- "Fill username field with {{TEST_USERNAME}}"
- "Fill password field with {{TEST_PASSWORD}}"
- "Click login button"
- "Wait for dashboard to load"
Run the suite:
/run-test-suite suite:e-commerce.yml env:test
# Run all smoke tests
/run-yaml-test tags:smoke env:dev
# Run tests that have both smoke AND login tags
/run-yaml-test tags:smoke,login env:dev
# Run tests that have smoke OR critical tags
/run-yaml-test tags:smoke|critical env:dev
# Run all tests in prod environment
/run-yaml-test env:prod
Development (.env.dev
):
BASE_URL=http://localhost:3000
TEST_USERNAME=dev@example.com
TEST_PASSWORD=devpass123
GENERATE_REPORT=true
REPORT_STYLE=overview
REPORT_PATH=reports/dev
Production (.env.prod
):
BASE_URL=https://prod.example.com
TEST_USERNAME=prod@example.com
TEST_PASSWORD=secureprodpass
GENERATE_REPORT=true
REPORT_STYLE=detailed
REPORT_PATH=reports/prod
claude-test update --backup --verbose
This creates a backup and shows detailed output during update.
- Check framework integrity:
claude-test check --verbose
- Validate your test syntax:
/validate-yaml-test file:your-test.yml
- Run with detailed reporting: Set
REPORT_STYLE=detailed
in your .env file - Check the generated HTML reports:
/view-reports-index
Create YAML files in the steps/
directory:
# steps/common-actions.yml
description: Common UI actions
steps:
- "Wait for page to load"
- "Take screenshot"
- "Scroll to top of page"
Then include in your tests:
# test-cases/my-test.yml
tags: [smoke]
steps:
- include: common-actions
- "Click submit button"
Currently, tests run sequentially with session optimization. Parallel execution is planned for future releases.
- Create separate
.env
files:.env.dev
,.env.test
,.env.prod
- Use environment variables in your tests:
{{BASE_URL}}
- Specify environment when running:
/run-yaml-test env:prod
# Check for issues
claude-test check --fix
# Or force reinstall
claude-test init --force
- Run
/view-reports-index
- Navigate between environment tabs (dev/test/prod)
- Click on any report card to view detailed results
- Reports are organized by timestamp for easy access
# Error: Framework not found in current directory
claude-test init
# Check versions
claude-test check --verbose
# Update framework
claude-test update
# On macOS/Linux, you might need sudo for global install
sudo npm install -g claude-test
- Validate test syntax:
/validate-yaml-test file:your-test.yml
- Check environment variables: Ensure all
{{VARIABLES}}
are defined - Verify step libraries: Make sure all
include:
references exist - Check Playwright MCP: Ensure Claude Code has Playwright integration
The framework includes comprehensive testing and validation:
- CLI Testing: Complete command validation and integration tests
- Cross-platform Support: Tested on macOS and Linux
- Version Management: Automatic compatibility checking
- Error Handling: Graceful failure modes and recovery
We welcome contributions! Please read our contributing guidelines before submitting pull requests.
This project is the official CLI tool for the claude-test framework. It contains:
- CLI Entry Point:
bin/claude-test.js
- Commander.js-based CLI with three main commands - Commands:
lib/commands/
- Implementation for init, update, and check commands - Utilities:
lib/utils/
- Core business logic (file management, version control) - Templates:
lib/templates/
- Framework files that get copied to user projects
npm test
- Run Jest test suite with 84.95% code coveragenpm run lint
- ESLint validationnpm run test:coverage
- Coverage analysis including .claude/scriptsnpm run sync-templates
- Sync framework templatesnpm run ci
- Complete CI pipeline
Comprehensive test coverage including:
- Unit tests for all core modules
- Integration tests for CLI commands
- Error handling and edge case validation
- CLI command execution testing
For practical usage examples and integration demonstrations, visit the companion project:
📖 claude-test-demo - Complete usage examples, test cases, and integration guides
For issues and questions:
- GitHub Issues: Report a bug
- Full Documentation: Full Documentation
- Demo Project: claude-code-playwright-mcp-test
- Claude Code Docs: https://docs.anthropic.com/en/docs/claude-code
MIT License - see LICENSE file for details.
Made with ❤️ by the Anthropic team for the Claude Code community.