This document provides comprehensive information about testing the Mayor West Mode CLI tool, including automated tests, manual testing procedures, and guidelines for contributors.
# Run all tests
npm test
# Run tests with coverage report
npm run test:coverage
# Run tests in watch mode (for development)
npm run test:watchThe test suite is located in cli.test.js and consists of 30 comprehensive tests covering:
- HTTPS URLs with and without
.gitextension - SSH URLs with and without
.gitextension - Invalid and malformed URL handling
- Support for both
https://github.com/owner/repoandgit@github.com:owner/repoformats
- Directory extraction from file paths
- Nested path handling
- Root-level file handling
- VS Code settings JSON validation
- Security constraint verification (blocked commands)
- Safe command auto-approval patterns
- Agent instruction template structure
- GitHub Actions workflow template structure
- Issue template structure
- All 5 required configuration files verified
- Critical vs. optional file designation
- Iteration limit validation (1-50 range)
- Invalid iteration limit rejection
- Merge strategy validation (SQUASH, MERGE, REBASE)
- Destructive command blocking (
rm,kill,git reset --hard) - Safe package manager command approval
- Iteration limit enforcement
- Empty git remote URL handling
- Non-GitHub URL handling
- GitHub URLs with subdomains
- Minimal setup mode filtering (critical files only)
- Custom setup mode with selective file creation
- All 5 commands supported: setup, verify, help, examples, status
- Proper categorization: configuration, agent, workflow, template
- Node.js 18+ installed
- Git repository initialized
- GitHub remote configured
node cli.js helpExpected Output:
- Usage instructions
- List of all commands
- Command descriptions
- Example commands
Validation:
- ✓ All commands listed
- ✓ Descriptions clear and accurate
- ✓ Examples provided
node cli.js examplesExpected Output:
- 3 example tasks (simple, medium, complex)
- Best practices section
- Task complexity guidelines
Validation:
- ✓ Examples cover different complexity levels
- ✓ Best practices are actionable
- ✓ Formatting is clear
node cli.js statusExpected Output:
- Git repository status
- Remote URL
- Current branch
- Configuration file status (✓ or ✗ for each)
Validation:
- ✓ Detects git repository correctly
- ✓ Shows correct remote URL
- ✓ Lists all 5 configuration files
- ✓ Accurately reports file existence
node cli.js verifyExpected Output:
- Check results for each file and git repository
- Pass/fail count (X/7 checks passed)
- Success or warning message
Validation:
- ✓ Checks all 7 items
- ✓ Accurately reports pass/fail
- ✓ Provides actionable next steps
node cli.js setupExpected Behavior:
- Validates git repository
- Validates GitHub remote
- Prompts for setup type (full/minimal/custom)
- Prompts for auto-merge preference
- Prompts for merge strategy
- Prompts for iteration limit
- Creates selected files
- Shows success message with next steps
Validation:
- ✓ Exits early if not a git repository
- ✓ Exits early if no GitHub remote
- ✓ Creates all selected files
- ✓ Files contain correct content
- ✓ Directories created recursively
- ✓ Next steps clearly explained
mkdir /tmp/test-non-git
cd /tmp/test-non-git
node /path/to/cli.js setupExpected: Error message indicating not a git repository, exit code 1
mkdir /tmp/test-no-remote
cd /tmp/test-no-remote
git init
node /path/to/cli.js setupExpected: Error message indicating no git remote found, exit code 1
mkdir /tmp/test-gitlab
cd /tmp/test-gitlab
git init
git remote add origin https://gitlab.com/owner/repo.git
node /path/to/cli.js setupExpected: Error message indicating remote doesn't point to GitHub, exit code 1
After running setup, verify each generated file:
- ✓ Valid JSON
- ✓
chat.tools.autoApproveistrue - ✓ Destructive commands blocked (
rm,kill, etc.) - ✓ Safe commands auto-approved (git commit/push, npm test/build)
- ✓
chat.agent.iterationLimitset correctly
- ✓ Contains "Your Mission" section
- ✓ Contains numbered steps for task execution
- ✓ Contains "Operating Principles" section
- ✓ Contains "Failure Recovery" section
- ✓ Contains "Safety Constraints" section
- ✓ Valid YAML syntax
- ✓ Triggers on pull_request events
- ✓ Filters for copilot actor
- ✓ Has approve and enable auto-merge steps
- ✓ Uses GitHub Actions v7
- ✓ Valid YAML syntax
- ✓ Triggers on workflow_dispatch, pull_request closed, schedule
- ✓ Cron schedule:
*/15 * * * *(every 15 minutes) - ✓ Finds unassigned mayor-task issues
- ✓ Triggers Copilot via comment
- ✓ Has YAML frontmatter
- ✓ Label:
mayor-task - ✓ Contains all required sections
- ✓ Provides clear structure for tasks
When adding new functionality to the CLI:
- Add unit tests for pure functions (URL parsing, validation, etc.)
- Test edge cases (empty strings, null values, invalid inputs)
- Test error handling (what happens when things go wrong)
- Update this guide with new test scenarios
describe('Feature Category', () => {
test('should do something specific', () => {
// Test implementation
});
});- ✓ Keep tests independent (no shared state)
- ✓ Test one thing per test
- ✓ Use descriptive test names
- ✓ Prefer pure function testing over mocking when possible
- ✓ Test both success and failure paths
The test suite is designed to run in CI/CD pipelines:
# Example GitHub Actions workflow
- name: Run tests
run: npm test
- name: Run tests with coverage
run: npm run test:coverage# Run specific test file
NODE_OPTIONS=--experimental-vm-modules npx jest cli.test.js
# Run tests matching a pattern
NODE_OPTIONS=--experimental-vm-modules npx jest -t "GitHub URL Parsing"NODE_OPTIONS=--experimental-vm-modules npx jest --verbose- Coverage reporting: Due to ES modules and the CLI structure, code coverage shows 0%. Tests validate business logic independently, which is actually better for maintainability.
- Interactive prompts: The test suite doesn't test interactive prompts directly (inquirer). Manual testing is required for these scenarios.
- File system operations: Tests validate logic, not actual file creation. Manual verification recommended after running setup.
When contributing to the test suite:
- Ensure all existing tests pass
- Add tests for new functionality
- Update this guide with new test scenarios
- Follow the existing test structure and naming conventions
For questions about testing:
- Review existing tests in
cli.test.js - Consult the Jest documentation: https://jestjs.io/
- Check this testing guide
Last Updated: January 15, 2026
Test Suite Version: 1.0.0
Total Tests: 30