from https://github.com/terryso/claude-test.git
🎯 English | 中文
YAML-based Playwright MCP testing framework CLI for OpenCode. 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 ci
npm pack
npm install -g xxxxxxxx.tgznpm ci
npm pack
npm install -g xxxxxxxx.tgzcd your-project
opencode-test initCreate 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-indexInitialize the testing framework in your current project directory.
opencode-test init [options]Options:
-f, --force- Force initialization even if framework already exists--verbose- Show detailed output during initialization
Example:
# Basic initialization
opencode-test init
# Force reinitialize with detailed output
opencode-test init --force --verboseUpdate the framework to the latest version.
opencode-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
opencode-test update --backup
# Preview changes without applying
opencode-test update --dry-run
# Detailed update process
opencode-test update --verboseCheck framework version and status.
opencode-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
opencode-test check
# Check and fix issues
opencode-test check --fix
# Detailed status report
opencode-test check --verboseAfter 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 opencode-test init, your project will contain:
.opencode/
├── commands/ # OpenCode 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
- OpenCode: 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.ymlIndividual 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:prodDevelopment (.env.dev):
BASE_URL=http://localhost:3000
TEST_USERNAME=dev@example.com
TEST_PASSWORD=devpass123
GENERATE_REPORT=true
REPORT_STYLE=overview
REPORT_PATH=reports/devProduction (.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/prodopencode-test update --backup --verboseThis creates a backup and shows detailed output during update.
- Check framework integrity:
opencode-test check --verbose - Validate your test syntax:
/validate-yaml-test file:your-test.yml - Run with detailed reporting: Set
REPORT_STYLE=detailedin 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
.envfiles:.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
opencode-test check --fix
# Or force reinstall
opencode-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
opencode-test init# Check versions
opencode-test check --verbose
# Update framework
opencode-test update# On macOS/Linux, you might need sudo for global install
sudo npm install -g opencode-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 OpenCode 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 opencode-test framework. It contains:
- CLI Entry Point:
bin/opencode-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 .opencode/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:
📖 opencode-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: opencode-test-demo
- OpenCode Docs: https://opencode.ai/docs
MIT License - see LICENSE file for details.
Made with ❤️ by the Anthropic team for the OpenCode community.